[cfe-commits] r61882 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaExprObjC.cpp test/SemaObjC/undef-class-messagin-error.m

Fariborz Jahanian fjahanian at apple.com
Wed Jan 7 13:01:42 PST 2009


Author: fjahanian
Date: Wed Jan  7 15:01:41 2009
New Revision: 61882

URL: http://llvm.org/viewvc/llvm-project?rev=61882&view=rev
Log:
Don't ICE when messaging on 'super' receiver when class
of category implementation is undeclared. Issue error instead.

Added:
    cfe/trunk/test/SemaObjC/undef-class-messagin-error.m
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=61882&r1=61881&r2=61882&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Jan  7 15:01:41 2009
@@ -536,6 +536,8 @@
      "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,

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=61882&r1=61881&r2=61882&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jan  7 15:01:41 2009
@@ -190,10 +190,13 @@
   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);

Added: cfe/trunk/test/SemaObjC/undef-class-messagin-error.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/undef-class-messagin-error.m?rev=61882&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/undef-class-messagin-error.m (added)
+++ cfe/trunk/test/SemaObjC/undef-class-messagin-error.m Wed Jan  7 15:01:41 2009
@@ -0,0 +1,13 @@
+// RUN: clang -fsyntax-only -verify %s
+
+ at interface _Child
++ (int) flashCache;
+ at end
+
+ at interface Child (Categ) // expected-error {{cannot find interface declaration for 'Child'}}
++ (int) flushCache2;
+ at end
+
+ at 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'}}
+ at end





More information about the cfe-commits mailing list