[PATCH] D87350: [AST][RecoveryExpr] Fix a crash on undeduced type.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 9 00:25:13 PDT 2020


hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hokein requested review of this revision.

We should not capture the type if the function return type is undeduced.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87350

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===================================================================
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -105,3 +105,9 @@
 int v = arr(); // expected-error {{array types cannot be value-initialized}} \
                   expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'test8::arr'}}
 }
+
+namespace test9 {
+auto f(); // expected-note {{candidate function not viable}}
+// verify no crash on evaluating the size of undeduced auto type.
+static_assert(sizeof(f(1)), ""); // expected-error {{no matching function for call to 'f'}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -12853,7 +12853,7 @@
     if (Candidate.Function->isInvalidDecl())
       return;
     QualType T = Candidate.Function->getReturnType();
-    if (T.isNull())
+    if (T.isNull() || T->isUndeducedType())
       return;
     if (!Result)
       Result = T;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87350.290654.patch
Type: text/x-patch
Size: 1112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200909/d9e466c4/attachment-0001.bin>


More information about the cfe-commits mailing list