From: Argyrios Kyrtzidis Date: Tue, 13 Mar 2012 01:09:36 +0000 (+0000) Subject: Fix crash at @implementation with a forward reference as base class. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd707abbc758149d9f7d37bd0b25298455c678b2;p=clang Fix crash at @implementation with a forward reference as base class. rdar://11020003 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152596 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 27bdcd6c8c..d224f1058a 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -925,6 +925,8 @@ Decl *Sema::ActOnStartClassImplementation( Diag(PrevDecl->getLocation(), diag::note_previous_definition); } else { SDecl = dyn_cast_or_null(PrevDecl); + if (SDecl && !SDecl->hasDefinition()) + SDecl = 0; if (!SDecl) Diag(SuperClassLoc, diag::err_undef_superclass) << SuperClassname << ClassName; diff --git a/test/ASTMerge/Inputs/interface2.m b/test/ASTMerge/Inputs/interface2.m index 3fb43f5930..2133bd1381 100644 --- a/test/ASTMerge/Inputs/interface2.m +++ b/test/ASTMerge/Inputs/interface2.m @@ -69,7 +69,7 @@ @end // Forward-declared interface -@class I12, I10; +@class I10; @interface I12 @end @interface I11 @end diff --git a/test/SemaObjC/invalid-code.m b/test/SemaObjC/invalid-code.m index 7b6591205b..4ba34f0e47 100644 --- a/test/SemaObjC/invalid-code.m +++ b/test/SemaObjC/invalid-code.m @@ -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