diff options
author | Steve Naroff <snaroff@apple.com> | 2008-03-28 21:37:05 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-03-28 21:37:05 +0000 |
commit | 0de4199ca0c706b7b5826a9b41c4988bf210d03e (patch) | |
tree | ef3636f7cf0de002bd8fa22235298713ca58e258 | |
parent | b8654202ddf0c182f3a1a565a18add5488b2faba (diff) | |
download | bcm5719-llvm-0de4199ca0c706b7b5826a9b41c4988bf210d03e.tar.gz bcm5719-llvm-0de4199ca0c706b7b5826a9b41c4988bf210d03e.zip |
Make sure Sema::ActOnClassMessage() correctly diagnoses "super".
llvm-svn: 48924
-rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 5 | ||||
-rw-r--r-- | clang/test/Sema/undef-superclass-1.m | 6 |
3 files changed, 12 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index c3825624e4a..a6e6529e5f6 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -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 diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 4cf435c3315..1a274e126e0 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -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"); diff --git a/clang/test/Sema/undef-superclass-1.m b/clang/test/Sema/undef-superclass-1.m index 822b97185b1..7e12463654f 100644 --- a/clang/test/Sema/undef-superclass-1.m +++ b/clang/test/Sema/undef-superclass-1.m @@ -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 |