llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> This is an error case that results in a null Record, so don't crash later in that case. Fixes #<!-- -->173941 --- Full diff: https://github.com/llvm/llvm-project/pull/174193.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2) - (modified) clang/test/AST/ByteCode/cxx03.cpp (+10) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 4daab0702f147..67980676dcd30 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3258,6 +3258,8 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) { bool ZeroInit = E->requiresZeroInitialization(); if (ZeroInit) { const Record *R = getRecord(E->getType()); + if (!R) + return false; if (!this->visitZeroRecordInitializer(R, E)) return false; diff --git a/clang/test/AST/ByteCode/cxx03.cpp b/clang/test/AST/ByteCode/cxx03.cpp index 58d7f3632082d..ff81ed04e8334 100644 --- a/clang/test/AST/ByteCode/cxx03.cpp +++ b/clang/test/AST/ByteCode/cxx03.cpp @@ -46,3 +46,13 @@ struct S { vi4b w; }; const int s = S().w[1]; + +namespace NullRecord { + struct S { + int arr[1024 * 1024 * 1024]; + s = {1, {2}}; // both-error {{a type specifier is required for all declarations}} \ + // both-warning {{default member initializer for non-static data member is a C++11 extension}} + }; + + S s[2] = {}; +} `````````` </details> https://github.com/llvm/llvm-project/pull/174193 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
