Skip to content
Snippets Groups Projects
Commit 46257d7e authored by Eric Fiselier's avatar Eric Fiselier
Browse files

[Sema] Prevent using member declaration diagnostic if the base class is invalid.

Summary:
Once a base class has been made invalid (by a static_assert for example) all using-member declarations in the derived classes will result in a "not a base class" diagnostic. This diagnostic is very misleading and should not be emitted.

This change is needed to help libc++ produce reasonable diagnostics in `std::optional` and `std::variant`.  

Reviewers: rsmith, majnemer, aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25430

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283755 91177308-0d34-0410-b5e6-96231b3b80d8
parent 61a39e4b
No related branches found
No related tags found
No related merge requests found
......@@ -9470,11 +9470,13 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc,
return true;
}
 
Diag(SS.getRange().getBegin(),
diag::err_using_decl_nested_name_specifier_is_not_base_class)
<< SS.getScopeRep()
<< cast<CXXRecordDecl>(CurContext)
<< SS.getRange();
if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
Diag(SS.getRange().getBegin(),
diag::err_using_decl_nested_name_specifier_is_not_base_class)
<< SS.getScopeRep()
<< cast<CXXRecordDecl>(CurContext)
<< SS.getRange();
}
return true;
}
 
......
......@@ -92,3 +92,12 @@ namespace aliastemplateinst {
template struct APtr<int>; // expected-error{{elaborated type refers to a type alias template}}
}
namespace DontDiagnoseInvalidTest {
template <bool Value> struct Base {
static_assert(Value, ""); // expected-error {{static_assert failed}}
};
struct Derived : Base<false> { // expected-note {{requested here}}
using Base<false>::Base; // OK. Don't diagnose that 'Base' isn't a base class of Derived.
};
} // namespace DontDiagnoseInvalidTest
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment