-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] fix(85447): clang 18.1.0 crashes in clang::ASTContext::getTypeInfoImpl #89850
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
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) ChangesFixes #85447 Full diff: https://github.com/llvm/llvm-project/pull/89850.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5fed554d9e25c3..debe0d9e865362 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5789,6 +5789,9 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
Record->getLocation(), /*IdentifierInfo=*/nullptr,
Context.getTypeDeclType(Record), TInfo, SC);
+ if (Invalid)
+ Anon->setInvalidDecl();
+
ProcessDeclAttributes(S, Anon, Dc);
// Default-initialize the implicit variable. This initialization will be
diff --git a/clang/test/Sema/incomplete-struct-decl.cpp b/clang/test/Sema/incomplete-struct-decl.cpp
new file mode 100644
index 00000000000000..21e445fa170f94
--- /dev/null
+++ b/clang/test/Sema/incomplete-struct-decl.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+template <class a> using __impl_of = a; // expected-note {{'__impl_of' declared here}} \
+ expected-note {{template is declared here}}
+struct { // expected-error {{anonymous structs and classes must be class members}} \
+ expected-note {{to match this '{'}}
+ __impl_; // expected-error {{no template named '__impl_'; did you mean '__impl_of'?}} \
+ expected-error {{cannot specify deduction guide for alias template '__impl_of'}} \
+ expected-error {{expected ';' after struct}}
+ // expected-error {{expected '}'}}
|
Can you add a changelog entry indicating the issue fixed? |
@cor3ntin Thanks for pointing this out. I've updated the PR description. Were you referring to this changelog, or is there something else I should add? |
@a-tarasyuk in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Congratulations on your first contribution!
Will you need me to merge that PR for you?
@cor3ntin If no additional feedback is needed, it would be great if you could proceed with the merge. thanks |
@a-tarasyuk Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Fixes #85447
This PR resolves a crash in
ActOnUninitializedDecl
due to an oversight in updating theisInvalidDecl
state before invocation. The crash occurs due to a missing invocation ofsetInvalidDecl()
for an invalidAnon
declaration. To address this issue, thesetInvalidDecl()
method is now properly invoked to mark theAnon
declaration as invalid before runningActOnUninitializedDecl()
.