]> granicus.if.org Git - clang/commitdiff
Make sure Sema::ActOnClassMessage() correctly diagnoses "super".
authorSteve Naroff <snaroff@apple.com>
Fri, 28 Mar 2008 21:37:05 +0000 (21:37 +0000)
committerSteve Naroff <snaroff@apple.com>
Fri, 28 Mar 2008 21:37:05 +0000 (21:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48924 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaExprObjC.cpp
test/Sema/undef-superclass-1.m

index c3825624e4a567b3a089001d0fa4755952c4d178..a6e6529e5f67381d28129d5ebc4c669b74ed6514 100644 (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
index 4cf435c331529774fb87a549e285e993a71f71c5..1a274e126e020504bc0c43016a0d9ffd67dc2e7c 100644 (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");
index 822b97185b103be22cb488335f1c819ba68c91d2..7e12463654f3d3085fbf867972ccb73b4d63dfd8 100644 (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