diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 0f7f0ffa75afa09a8b03f4dad69862c4950c1194..7eca6c1b6163f4b19d2606128a8072d6c89323cc 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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; } diff --git a/test/SemaCXX/using-decl-templates.cpp b/test/SemaCXX/using-decl-templates.cpp index d766bb3ac6bf5702d8a609738e22560168475cca..3b2b8e15c83ab797939503a74fdda853826cdaba 100644 --- a/test/SemaCXX/using-decl-templates.cpp +++ b/test/SemaCXX/using-decl-templates.cpp @@ -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