Skip to content

Commit cd132dc

Browse files
authored
[clang] fix(85447): clang 18.1.0 crashes in clang::ASTContext::getTypeInfoImpl (#89850)
Fixes #85447 --- This PR resolves a crash in `ActOnUninitializedDecl` due to an oversight in updating the `isInvalidDecl` state before invocation. The crash occurs due to a missing invocation of `setInvalidDecl()` for an invalid `Anon` declaration. To address this issue, the `setInvalidDecl()` method is now properly invoked to mark the `Anon` declaration as invalid before running `ActOnUninitializedDecl()`.
1 parent 8bec964 commit cd132dc

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

clang/docs/ReleaseNotes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ Bug Fixes to C++ Support
649649
- Fix a bug on template partial specialization with issue on deduction of nontype template parameter
650650
whose type is `decltype(auto)`. Fixes (#GH68885).
651651
- Clang now correctly treats the noexcept-specifier of a friend function to be a complete-class context.
652+
- Fix an assertion failure when parsing an invalid members of an anonymous class. (#GH85447)
652653

653654
Bug Fixes to AST Handling
654655
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaDecl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -5790,6 +5790,9 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
57905790
Anon = VarDecl::Create(Context, Owner, DS.getBeginLoc(),
57915791
Record->getLocation(), /*IdentifierInfo=*/nullptr,
57925792
Context.getTypeDeclType(Record), TInfo, SC);
5793+
if (Invalid)
5794+
Anon->setInvalidDecl();
5795+
57935796
ProcessDeclAttributes(S, Anon, Dc);
57945797

57955798
// Default-initialize the implicit variable. This initialization will be
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_cc1 -x c++ -fsyntax-only -verify=cxx,expected %s
2+
3+
template <class a> using __impl_of = a; // expected-note {{'__impl_of' declared here}} \
4+
expected-note {{template is declared here}}
5+
struct { // expected-error {{anonymous structs and classes must be class members}} \
6+
expected-note {{to match this '{'}}
7+
__impl_; // expected-error {{no template named '__impl_'; did you mean '__impl_of'?}} \
8+
expected-error {{cannot specify deduction guide for alias template '__impl_of'}} \
9+
expected-error {{expected ';' after struct}}
10+
// expected-error {{expected '}'}}

0 commit comments

Comments
 (0)