[PATCH] D82086: [AST][RecoveryExpr] Fix a crash: don't attach error-type base specifiers.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 24 01:34:56 PDT 2020


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()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82086.272931.patch
Type: text/x-patch
Size: 1142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200624/8804c605/attachment-0001.bin>


More information about the cfe-commits mailing list