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)
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)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits