]> granicus.if.org Git - clang/commitdiff
objc: don't crash if primary class is missing and continuation class
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 2 Feb 2012 00:49:12 +0000 (00:49 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 2 Feb 2012 00:49:12 +0000 (00:49 +0000)
is declaring ivars. // rdar://10752081

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149573 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaObjC/continuation-class-err.m

index 87bcfe9127d4935ac810458c143aa07a450f4d11..6ace744fc30dae5bec2c8af617a6aa91c4a99e60 100644 (file)
@@ -9045,6 +9045,8 @@ Decl *Sema::ActOnIvar(Scope *S,
                                         : ObjCIvarDecl::None;
   // Must set ivar's DeclContext to its enclosing interface.
   ObjCContainerDecl *EnclosingDecl = cast<ObjCContainerDecl>(CurContext);
+  if (!EnclosingDecl || EnclosingDecl->isInvalidDecl())
+    return 0;
   ObjCContainerDecl *EnclosingContext;
   if (ObjCImplementationDecl *IMPDecl =
       dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
index 700cf61eedb59c5efac0484f12c5fc03657f6f79..ad8b90955fa5bc1f243506f56019b4711e466ddc 100644 (file)
 @synthesize fee = _fee;
 @end
 
+// rdar://10752081
+@interface MyOtherClass() // expected-error {{cannot find interface declaration for 'MyOtherClass'}}
+{
+ id array;
+}
+@end
+
+@implementation MyOtherClass // expected-warning {{cannot find interface declaration for 'MyOtherClass'}}
+@end