[PATCH] D80980: [AST] Fix a null initializer crash for InitListExpr
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 2 02:13:02 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG97b8dabba5c5: [AST] Fix a null initializer crash for InitListExpr (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80980/new/
https://reviews.llvm.org/D80980
Files:
clang/lib/Sema/SemaInit.cpp
clang/test/AST/ast-dump-recovery.cpp
Index: clang/test/AST/ast-dump-recovery.cpp
===================================================================
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -181,3 +181,14 @@
// Verified that the generated call operator is invalid.
// CHECK: |-CXXMethodDecl {{.*}} invalid operator() 'auto () const -> auto'
using Escape = decltype([] { return undef(); }());
+
+// CHECK: VarDecl {{.*}} NoCrashOnInvalidInitList
+// CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>' contains-errors lvalue
+// CHECK-NEXT: `-InitListExpr
+// CHECK-NEXT: `-DesignatedInitExpr {{.*}} 'void'
+// CHECK-NEXT: `-CXXNullPtrLiteralExpr {{.*}} 'nullptr_t'
+struct {
+ int& abc;
+} NoCrashOnInvalidInitList = {
+ .abc = nullptr,
+};
Index: clang/lib/Sema/SemaInit.cpp
===================================================================
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1638,7 +1638,7 @@
expr = Result.getAs<Expr>();
// FIXME: Why are we updating the syntactic init list?
- if (!VerifyOnly)
+ if (!VerifyOnly && expr)
IList->setInit(Index, expr);
if (hadError)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80980.267823.patch
Type: text/x-patch
Size: 1153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200602/9dc9136f/attachment.bin>
More information about the cfe-commits
mailing list