Skip to content

Commit 1511e98

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 2db61c1 commit 1511e98

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
@@ -18070,6 +18070,9 @@ Decl *Sema::ActOnIvar(Scope *S,
1807018070
DeclStart, Loc, II, T,
1807118071
TInfo, ac, (Expr *)BitfieldWidth);
1807218072

18073+
if (T->containsErrors())
18074+
NewID->setInvalidDecl();
18075+
1807318076
if (II) {
1807418077
NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
1807518078
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)