Skip to content

Commit 68e720d

Browse files
ahatanakahatanaka
authored andcommitted
Mark an ObjCIvarDecl as invalid if its type contains errors (llvm#68001)
This fixes an assertion failure in InitializationSequence::Perform.
1 parent 3c8c3f0 commit 68e720d

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
@@ -18446,6 +18446,9 @@ Decl *Sema::ActOnIvar(Scope *S,
1844618446
DeclStart, Loc, II, T,
1844718447
TInfo, ac, (Expr *)BitfieldWidth);
1844818448

18449+
if (T->containsErrors())
18450+
NewID->setInvalidDecl();
18451+
1844918452
if (II) {
1845018453
NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
1845118454
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)