This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rGf0084c3bcbc2: [AST][RecoveryExpr] Fix a crash: don't 
attach error-type base specifiers. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D82086?vs=271680&id=272931#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82086/new/

https://reviews.llvm.org/D82086

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/invalid-template-base-specifier.cpp


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===================================================================
--- /dev/null
+++ 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 <typename T>
+struct Crash : decltype(Foo(T())) { // expected-error {{no matching function 
for call to 'Foo'}}
+  Crash(){};
+};
+
+void test() { Crash<int>(); } // expected-note {{in instantiation of template 
class}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ 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()) {


Index: clang/test/SemaCXX/invalid-template-base-specifier.cpp
===================================================================
--- /dev/null
+++ 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 <typename T>
+struct Crash : decltype(Foo(T())) { // expected-error {{no matching function for call to 'Foo'}}
+  Crash(){};
+};
+
+void test() { Crash<int>(); } // expected-note {{in instantiation of template class}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ 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()) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to