Skip to content

Revert "[Sema] Fix crash on invalid code with parenthesized aggregate initialization" #76272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Dec 22, 2023

Reverts #76232 and 7ab16fb to recover build bots.

Breaks libc++ tests, details in #76232

#76228

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Dec 22, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 22, 2023

@llvm/pr-subscribers-clang

Author: Vitaly Buka (vitalybuka)

Changes

Reverts llvm/llvm-project#76232 to recover build bots.

Breaks libc++ tests, details in #76232

#76263


Full diff: https://github.com/llvm/llvm-project/pull/76272.diff

2 Files Affected:

  • (modified) clang/lib/Sema/SemaInit.cpp (-8)
  • (removed) clang/test/SemaCXX/crash-GH76228.cpp (-28)
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index cc9db5ded1149a..61d244f3bb9798 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<RecordType>()) {
     bool IsUnion = RT->isUnionType();
     const CXXRecordDecl *RD = cast<CXXRecordDecl>(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 33a9395823127e..00000000000000
--- 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);

@vitalybuka vitalybuka merged commit 2205d23 into main Dec 22, 2023
@vitalybuka vitalybuka deleted the revert-76232-parens branch December 22, 2023 23:20
ilya-biryukov added a commit that referenced this pull request Jan 2, 2024
…e initialization" (#76272)

With updates the libc++ tests.

This reverts commit 2205d23 and relands
86dc6e1 and
7ab16fb.

Original commit was reverted because of failing libc++ tests, see #76232 for
the discussion.

The errors in the tests are spurious in the first place (coming from initialization
of invalid classes), so update the tests to match new behavior that does
not show those errors.
mordante added a commit that referenced this pull request Jan 3, 2024
…aggregate initialization" (#76272)"

This reverts commit 02347fc.

These changes break the libc++ CI again.
I'll look at a better solution later.
mordante added a commit to mordante/llvm-project that referenced this pull request Jan 3, 2024
…te initialization" (llvm#76272)""

With updates the libc++ tests.

This reverts commit 2205d23 and relands
86dc6e1 and
7ab16fb.

Original commit was reverted because of failing libc++ tests, see llvm#76232 for
the discussion.

The errors in the tests are spurious in the first place (coming from initialization
of invalid classes), so update the tests to match new behavior that does
not show those errors.
mordante added a commit that referenced this pull request Jan 5, 2024
#76833)

…te initialization" (#76272)""

With updates the libc++ tests.

This reverts commit 2205d23 and relands
86dc6e1 and
7ab16fb.

Original commit was reverted because of failing libc++ tests, see #76232
for the discussion.

The errors in the tests are spurious in the first place (coming from
initialization of invalid classes), so update the tests to match new
behavior that does not show those errors.

The original patch was written by @ilya-biryukov 

To fix the CI two libc++ tests are temporary disabled for clang-18.
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
llvm#76833)

…te initialization" (llvm#76272)""

With updates the libc++ tests.

This reverts commit 2205d23 and relands
86dc6e1 and
7ab16fb.

Original commit was reverted because of failing libc++ tests, see llvm#76232
for the discussion.

The errors in the tests are spurious in the first place (coming from
initialization of invalid classes), so update the tests to match new
behavior that does not show those errors.

The original patch was written by @ilya-biryukov 

To fix the CI two libc++ tests are temporary disabled for clang-18.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants