This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Fix the broken test after D82657.
ClosedPublic

Authored by hokein on Aug 27 2020, 12:42 AM.

Details

Reviewers
ldionne
vvereschaka
Group Reviewers
Restricted Project
Commits
rG3f8a0ecdaa63: [libcxx] Fix the broken test after D82657.
Summary

D82657 slightly changes clang's diagnostic. After that commit, clang emits a secondary diagnostic in one of the libcxx test, this patch fixes it.

Diff Detail

Event Timeline

hokein created this revision.Aug 27 2020, 12:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2020, 12:42 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
hokein requested review of this revision.Aug 27 2020, 12:42 AM
hokein edited the summary of this revision. (Show Details)Aug 27 2020, 12:47 AM
hokein edited reviewers, added: ldionne, vvereschaka; removed: Restricted Project.Aug 27 2020, 12:54 AM
Herald added a reviewer: Restricted Project. · View Herald TranscriptAug 27 2020, 12:54 AM
Herald added a subscriber: dexonsmith. · View Herald Transcript

I'm not sure this is the correct solution to fix the failing test due to the new diagnostic of the compiler.

The test will pass if it runs under the trunk clang; and it fails if it runs under an old clang;

After D82657

Any ideas?

ldionne requested changes to this revision.Aug 27 2020, 6:14 AM

I'm not sure this is the correct solution to fix the failing test due to the new diagnostic of the compiler.

The test will pass if it runs under the trunk clang; and it fails if it runs under an old clang;

After D82657

Any ideas?

The correct fix is to ensure that Clang doesn't produce a second diagnostic, since that second diagnostic is bogus. Working around the issue by annotating the libc++ tests isn't the right solution.

This revision now requires changes to proceed.Aug 27 2020, 6:14 AM
sammccall added a subscriber: sammccall.EditedAug 27 2020, 8:26 AM

@hokein here's a minimized version:

template <int>
struct flag {
  static constexpr bool value = true;
};

template <class T>
struct trait : flag<sizeof(T)> {};

template <class T, bool Inferred = trait<T>::value>
struct a {};

template <class T>
class b {
  a<T> x;
  using U = a<T>;
};

template <int>
struct Impossible {
  static_assert(false, "");
};

constexpr auto v = trait<b<Impossible<0>>>::value;

I see the static_assert and a spurious:

error: no member named 'value' in 'trait<Impossible<0>>'

It does look like a bug somewhere in clang.

Strangely, -Xclang -fno-recovery-ast-type doesn't make it go away - how sure are we that your patch is the culprit? And how sure are we that those flags work properly?

Strangely, -Xclang -fno-recovery-ast-type doesn't make it go away - how sure are we that your patch is the culprit? And how sure are we that those flags work properly?

Turns out this is an existing clang bug, and my simplified testcase shows a variant that is broken with or without -frecovery-ast-type.

So it's good that libcxx happens not to be triggering the bug on this codepath at the moment, but it's mostly getting lucky.

ISTM the best path is to suppress this failure (like in this patch, but with a FIXME) and then try to fix the latent clang bug that was uncovered.
(These sort of FIXMEs are pretty common with secondary diagnostics and there's still a net improvement)

In that case, please use // expected-error@memory:* 0+ {{no member named 'value' in}} and add a proper FIXME comment with a link to this review or similar. The 0+ will make sure the test passes whether or not Clang emits the secondary diagnostic.

hokein updated this revision to Diff 288404.Aug 27 2020, 11:34 AM

add FIXME.

ldionne accepted this revision.Aug 27 2020, 11:36 AM

Please add a link to https://reviews.llvm.org/D86685 and commit this.

This revision is now accepted and ready to land.Aug 27 2020, 11:36 AM

In that case, please use // expected-error@memory:* 0+ {{no member named 'value' in}} and add a proper FIXME comment with a link to this review or similar. The 0+ will make sure the test passes whether or not Clang emits the secondary diagnostic.

Thanks. Added one. I will followup to fix this bogus diagnostic in clang.

This revision was landed with ongoing or failed builds.Aug 27 2020, 12:12 PM
This revision was automatically updated to reflect the committed changes.