]> granicus.if.org Git - clang/commitdiff
Fix crash at @implementation with a forward reference as base class.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 13 Mar 2012 01:09:36 +0000 (01:09 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 13 Mar 2012 01:09:36 +0000 (01:09 +0000)
rdar://11020003

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

lib/Sema/SemaDeclObjC.cpp
test/ASTMerge/Inputs/interface2.m
test/SemaObjC/invalid-code.m

index 27bdcd6c8cda957cb6ca68347e5ece23b43aad6d..d224f1058a06ca893721602eb6d99cd9a2d87665 100644 (file)
@@ -925,6 +925,8 @@ Decl *Sema::ActOnStartClassImplementation(
       Diag(PrevDecl->getLocation(), diag::note_previous_definition);
     } else {
       SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
+      if (SDecl && !SDecl->hasDefinition())
+        SDecl = 0;
       if (!SDecl)
         Diag(SuperClassLoc, diag::err_undef_superclass)
           << SuperClassname << ClassName;
index 3fb43f5930c38b8600d9317aa57b0f7dca49c1bb..2133bd1381aa9d41a48637151201142f4e8690c7 100644 (file)
@@ -69,7 +69,7 @@
 @end
 
 // Forward-declared interface
-@class I12, I10;
+@class I10; @interface I12 @end
 @interface I11
 @end
 
index 7b6591205b45e39f0005e4abed05450922ca124a..4ba34f0e47df09ad56abc9e1a3a8b38279a15ae0 100644 (file)
@@ -42,3 +42,9 @@ void foo() {
 @end
 
 @end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@class ForwardBase;
+@implementation SomeI : ForwardBase // expected-error {{cannot find interface declaration for 'ForwardBase', superclass of 'SomeI'}} \
+                                    // expected-warning {{cannot find interface declaration for 'SomeI'}}
+-(void)meth {}
+@end