Make sure Sema::ActOnClassMessage() correctly diagnoses "super".

llvm-svn: 48924
This commit is contained in:
Steve Naroff 2008-03-28 21:37:05 +00:00
parent b8654202dd
commit 0de4199ca0
3 changed files with 12 additions and 1 deletions

View File

@ -477,6 +477,8 @@ DIAG(error_missing_method_context, ERROR,
"missing context for method declaration")
DIAG(error_bad_receiver_type, ERROR,
"bad receiver type '%0'")
DIAG(error_no_super_class, ERROR,
"no super class declared in @interface for '%0'")
//===----------------------------------------------------------------------===//
// Semantic Analysis

View File

@ -146,7 +146,10 @@ Sema::ExprResult Sema::ActOnClassMessage(
ObjCInterfaceDecl* ClassDecl = 0;
if (!strcmp(receiverName->getName(), "super") && CurMethodDecl) {
ClassDecl = CurMethodDecl->getClassInterface()->getSuperClass();
if (ClassDecl && CurMethodDecl->isInstance()) {
if (!ClassDecl)
return Diag(lbrac, diag::error_no_super_class,
CurMethodDecl->getClassInterface()->getName());
if (CurMethodDecl->isInstance()) {
// Synthesize a cast to the super class. This hack allows us to loosely
// represent super without creating a special expression node.
IdentifierInfo &II = Context.Idents.get("self");

View File

@ -18,3 +18,9 @@
@interface INTF1 // expected-error {{duplicate interface declaration for class 'INTF1'}}
@end
@implementation SUPER
- (void)dealloc {
[super dealloc]; // expected-error {{no super class declared in @interface for 'SUPER'}}
}
@end