Properly pop out of Objective-C method declarations when they are (ill-formedly)

found within contexts other than the translation unit.

llvm-svn: 110417
This commit is contained in:
John McCall 2010-08-06 00:46:05 +00:00
parent c2107d2eaa
commit dc9796e23a
2 changed files with 8 additions and 1 deletions

View File

@ -343,8 +343,10 @@ DeclContext *Sema::getContainingDC(DeclContext *DC) {
return DC;
}
// ObjCMethodDecls are parsed (for some reason) outside the context
// of the class.
if (isa<ObjCMethodDecl>(DC))
return Context.getTranslationUnitDecl();
return DC->getLexicalParent()->getLexicalParent();
return DC->getLexicalParent();
}

View File

@ -23,5 +23,10 @@ namespace C {
@implementation A(C) //expected-error{{Objective-C declarations may only appear in global scope}}
@end
@interface B @end //expected-error{{Objective-C declarations may only appear in global scope}}
@implementation B //expected-error{{Objective-C declarations may only appear in global scope}}
+ (void) foo {}
@end
}