]> granicus.if.org Git - clang/commitdiff
Don't ICE when messaging on 'super' receiver when class
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 7 Jan 2009 21:01:41 +0000 (21:01 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 7 Jan 2009 21:01:41 +0000 (21:01 +0000)
of category implementation is undeclared. Issue error instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61882 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaExprObjC.cpp
test/SemaObjC/undef-class-messagin-error.m [new file with mode: 0644]

index a29f43f1dd5ced0850fa7a284eb94ce428b52430..2577e65d3b603f319a758668cffb38d52d2946c2 100644 (file)
@@ -536,6 +536,8 @@ DIAG(error_bad_receiver_type, ERROR,
      "bad receiver type %0")
 DIAG(error_no_super_class, ERROR,
      "no super class declared in @interface for %0")
+DIAG(error_no_super_class_message, ERROR,
+     "no @interface declaration found in class messaging of %0")
 DIAG(error_missing_property_context, ERROR,
      "missing context for property implementation declaration")
 DIAG(error_bad_property_context, ERROR,
index e2825056c5755d64f4a91b7b47ac0857155afb7c..de99e182d66c2a8ac8f2d0e6653ea348f9105bab 100644 (file)
@@ -190,10 +190,13 @@ Sema::ExprResult Sema::ActOnClassMessage(
   if (receiverName->isStr("super")) {
     if (getCurMethodDecl()) {
       isSuper = true;
-      ClassDecl = getCurMethodDecl()->getClassInterface()->getSuperClass();
+      ObjCInterfaceDecl *OID = getCurMethodDecl()->getClassInterface();
+      if (!OID)
+        return Diag(lbrac, diag::error_no_super_class_message) 
+                      << getCurMethodDecl()->getDeclName();
+      ClassDecl = OID->getSuperClass();
       if (!ClassDecl)
-        return Diag(lbrac, diag::error_no_super_class)
-          << getCurMethodDecl()->getClassInterface()->getDeclName();
+        return Diag(lbrac, diag::error_no_super_class) << OID->getDeclName();
       if (getCurMethodDecl()->isInstance()) {
         QualType superTy = Context.getObjCInterfaceType(ClassDecl);
         superTy = Context.getPointerType(superTy);
diff --git a/test/SemaObjC/undef-class-messagin-error.m b/test/SemaObjC/undef-class-messagin-error.m
new file mode 100644 (file)
index 0000000..6d162ac
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: clang -fsyntax-only -verify %s
+
+@interface _Child
++ (int) flashCache;
+@end
+
+@interface Child (Categ) // expected-error {{cannot find interface declaration for 'Child'}}
++ (int) flushCache2;
+@end
+
+@implementation Child (Categ) // expected-error {{cannot find interface declaration for 'Child'}}
++ (int) flushCache2 { [super flashCache]; } // expected-error {{no @interface declaration found in class messaging of 'flushCache2'}}
+@end