From 2205d2334f3c859ad9f6c65ed950bfb3bb6f7cbe Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Fri, 22 Dec 2023 15:20:00 -0800 Subject: [PATCH] Revert "[Sema] Fix crash on invalid code with parenthesized aggregate initialization" (#76272) Reverts llvm/llvm-project#76232 and 7ab16fb5207fe187ab999f882069bd632d2e68e5 to recover build bots. Breaks libc++ tests, details in #76232 #76228 --- clang/lib/Sema/SemaInit.cpp | 8 ------- clang/test/SemaCXX/crash-GH76228.cpp | 28 ---------------------- clang/test/SemaCXX/paren-list-agg-init.cpp | 2 +- 3 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 clang/test/SemaCXX/crash-GH76228.cpp diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index cc9db5ded114..61d244f3bb97 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -5512,14 +5512,6 @@ static void TryOrBuildParenListInitialization( } else if (auto *RT = Entity.getType()->getAs()) { bool IsUnion = RT->isUnionType(); const CXXRecordDecl *RD = cast(RT->getDecl()); - if (RD->isInvalidDecl()) { - // Exit early to avoid confusion when processing members. - // We do the same for braced list initialization in - // `CheckStructUnionTypes`. - Sequence.SetFailed( - clang::InitializationSequence::FK_ParenthesizedListInitFailed); - return; - } if (!IsUnion) { for (const CXXBaseSpecifier &Base : RD->bases()) { diff --git a/clang/test/SemaCXX/crash-GH76228.cpp b/clang/test/SemaCXX/crash-GH76228.cpp deleted file mode 100644 index 33a939582312..000000000000 --- a/clang/test/SemaCXX/crash-GH76228.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -std=c++20 -verify %s -// Check we don't crash on incomplete members and bases when handling parenthesized initialization. -class incomplete; // expected-note@-0 3 {{forward declaration of 'incomplete'}} -struct foo { - int a; - incomplete b; - // expected-error@-1 {{incomplete type}} -}; -foo a1(0); - -struct one_int { - int a; -}; -struct bar : one_int, incomplete {}; -// expected-error@-1 {{incomplete type}} -bar a2(0); - -incomplete a3[3](1,2,3); -// expected-error@-1 {{incomplete type}} - -struct qux : foo { -}; -qux a4(0); - -struct fred { - foo a[3]; -}; -fred a5(0); diff --git a/clang/test/SemaCXX/paren-list-agg-init.cpp b/clang/test/SemaCXX/paren-list-agg-init.cpp index c1964a5a9eb0..f60b20e0d465 100644 --- a/clang/test/SemaCXX/paren-list-agg-init.cpp +++ b/clang/test/SemaCXX/paren-list-agg-init.cpp @@ -289,7 +289,7 @@ int test() { // used to crash S a(0, 1); S b(0); - S c(0, 0, 1); + S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' from a parenthesized list of values is a C++20 extension}} S d {0, 1}; S e {0};