Skip to content

Commit 1925c7a

Browse files
authored
Mark an ObjCIvarDecl as invalid if its type contains errors (#68001)
This fixes an assertion failure in InitializationSequence::Perform.
1 parent f793793 commit 1925c7a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18650,6 +18650,9 @@ Decl *Sema::ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D,
1865018650
ObjCIvarDecl *NewID = ObjCIvarDecl::Create(
1865118651
Context, EnclosingContext, DeclStart, Loc, II, T, TInfo, ac, BitWidth);
1865218652

18653+
if (T->containsErrors())
18654+
NewID->setInvalidDecl();
18655+
1865318656
if (II) {
1865418657
NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
1865518658
ForVisibleRedeclaration);

clang/test/SemaObjCXX/ivar-struct.mm

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify %s
2-
// expected-no-diagnostics
1+
// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -verify %s
32
@interface A {
43
struct X {
54
int x, y;
65
} X;
76
}
87
@end
8+
9+
static const uint32_t Count = 16; // expected-error {{unknown type name 'uint32_t'}}
10+
11+
struct S0 {
12+
S0();
13+
};
14+
15+
@interface C0
16+
@end
17+
18+
@implementation C0 {
19+
S0 ivar0[Count];
20+
}
21+
@end

0 commit comments

Comments
 (0)