[clang] Mark an ObjCIvarDecl as invalid if its type contains errors (PR #68001)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 2 09:08:01 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
<details>
<summary>Changes</summary>
This fixes an assertion failure in InitializationSequence::Perform.
---
Full diff: https://github.com/llvm/llvm-project/pull/68001.diff
2 Files Affected:
- (modified) clang/lib/Sema/SemaDecl.cpp (+3)
- (modified) clang/test/SemaObjCXX/ivar-struct.mm (+15-2)
``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9c2f1e83ed3fbe9..de6023105253f03 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -18622,6 +18622,9 @@ Decl *Sema::ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D,
ObjCIvarDecl *NewID = ObjCIvarDecl::Create(
Context, EnclosingContext, DeclStart, Loc, II, T, TInfo, ac, BitWidth);
+ if (T->containsErrors())
+ NewID->setInvalidDecl();
+
if (II) {
NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
ForVisibleRedeclaration);
diff --git a/clang/test/SemaObjCXX/ivar-struct.mm b/clang/test/SemaObjCXX/ivar-struct.mm
index c8c9ca9cbbf04f9..4a039a98abea6c1 100644
--- a/clang/test/SemaObjCXX/ivar-struct.mm
+++ b/clang/test/SemaObjCXX/ivar-struct.mm
@@ -1,8 +1,21 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
+// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -verify %s
@interface A {
struct X {
int x, y;
} X;
}
@end
+
+static const uint32_t Count = 16; // expected-error {{unknown type name 'uint32_t'}}
+
+struct S0 {
+ S0();
+};
+
+ at interface C0
+ at end
+
+ at implementation C0 {
+ S0 ivar0[Count];
+}
+ at end
``````````
</details>
https://github.com/llvm/llvm-project/pull/68001
More information about the cfe-commits
mailing list