diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-23 22:00:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-23 22:00:08 +0000 |
commit | 1829a6db2ec19e08061f0bb2f4c52a8e5e4efaf0 (patch) | |
tree | 5e6ec0f846885aefd6f18f3dbdaa9bc6e38c8c47 /lib/Sema/SemaDecl.cpp | |
parent | 60ff8ce5b2fda9c2a510f15d8b8504d0fc8c8e2f (diff) |
fix rdar://6611778, a redefinition of an interface was causing an
assertion when the ivars and method list was reset into the existing
interface. To fix this, mark decls as invalid when they are redefined,
and don't insert ivars/methods into invalid decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65340 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 4ec2dc6968..1786b6372b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3665,12 +3665,20 @@ void Sema::ActOnFields(Scope* S, AttributeList *Attr) { Decl *EnclosingDecl = static_cast<Decl*>(RecDecl); assert(EnclosingDecl && "missing record or interface decl"); - RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl); + + // If the decl this is being inserted into is invalid, then it may be a + // redeclaration or some other bogus case. Don't try to add fields to it. + if (EnclosingDecl->isInvalidDecl()) { + // FIXME: Deallocate fields? + return; + } + // Verify that all the fields are okay. unsigned NumNamedMembers = 0; llvm::SmallVector<FieldDecl*, 32> RecFields; + RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl); for (unsigned i = 0; i != NumFields; ++i) { FieldDecl *FD = cast_or_null<FieldDecl>(static_cast<Decl*>(Fields[i])); assert(FD && "missing field decl"); @@ -3782,9 +3790,8 @@ void Sema::ActOnFields(Scope* S, } } } - } - else if (ObjCImplementationDecl *IMPDecl = - dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { + } else if (ObjCImplementationDecl *IMPDecl = + dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) { assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl"); IMPDecl->setIVarList(ClsFields, RecFields.size(), Context); CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac); |