Skip to content

Commit

Permalink
Fix crash at @implementation with a forward reference as base class.
Browse files Browse the repository at this point in the history
rdar://11020003

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152596 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
akyrtzi committed Mar 13, 2012
1 parent 78dae24 commit cd707ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Sema/SemaDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/ASTMerge/Inputs/interface2.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ - (float)wibble:(int)a1 second:(int)a2;
@end

// Forward-declared interface
@class I12, I10;
@class I10; @interface I12 @end
@interface I11
@end

Expand Down
6 changes: 6 additions & 0 deletions test/SemaObjC/invalid-code.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ -(void) foo2 {}
@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

0 comments on commit cd707ab

Please sign in to comment.