diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2426,7 +2426,10 @@ TypeSourceInfo *TInfo, SourceLocation EllipsisLoc) { QualType BaseType = TInfo->getType(); - + if (BaseType->containsErrors()) { + // Already emitted a diagnostic when parsing the error type. + return nullptr; + } // C++ [class.union]p1: // A union shall not have base classes. if (Class->isUnion()) { diff --git a/clang/test/SemaCXX/invalid-template-base-specifier.cpp b/clang/test/SemaCXX/invalid-template-base-specifier.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaCXX/invalid-template-base-specifier.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -frecovery-ast -verify %s + +bool Foo(int *); // expected-note {{candidate function not viable}} + +template +struct Crash : decltype(Foo(T())) { // expected-error {{no matching function for call to 'Foo'}} + Crash(){}; +}; + +void test() { Crash(); } // expected-note {{in instantiation of template class}}