Skip to content

Commit f4e4e7b

Browse files
committed
fix(85447): refine handling of incomplete anonymous struct declarations
1 parent 145176d commit f4e4e7b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/Sema/SemaDecl.cpp

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

57945797
// Default-initialize the implicit variable. This initialization will be
Lines changed: 10 additions & 0 deletions
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)