[llvm-branch-commits] [cfe-branch] r71297 - in /cfe/branches/Apple/Dib: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprObjC.cpp test/SemaObjC/forward-class-receiver.m

Mike Stump mrs at apple.com
Fri May 8 16:58:10 PDT 2009


Author: mrs
Date: Fri May  8 18:58:10 2009
New Revision: 71297

URL: http://llvm.org/viewvc/llvm-project?rev=71297&view=rev
Log:
Merge in 71278:

Warn if forward class is used as a receiver.

Added:
    cfe/branches/Apple/Dib/test/SemaObjC/forward-class-receiver.m
      - copied unchanged from r71278, cfe/trunk/test/SemaObjC/forward-class-receiver.m
Modified:
    cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp

Modified: cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td?rev=71297&r1=71296&r2=71297&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/Apple/Dib/include/clang/Basic/DiagnosticSemaKinds.td Fri May  8 18:58:10 2009
@@ -1690,6 +1690,8 @@
 
 // Type
 def ext_invalid_sign_spec : Extension<"'%0' cannot be signed or unsigned">;
+def warn_receiver_forward_class : Warning<
+    "receiver %0 is a forward class and corresponding @interface may not exist">;
 def warn_missing_declspec : Warning<
   "declaration specifier missing, defaulting to 'int'">;
 def warn_missing_type_specifier : Warning<

Modified: cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp?rev=71297&r1=71296&r2=71297&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Sema/SemaExprObjC.cpp Fri May  8 18:58:10 2009
@@ -422,7 +422,15 @@
   assert(ClassDecl && "missing interface declaration");
   ObjCMethodDecl *Method = 0;
   QualType returnType;
-  Method = ClassDecl->lookupClassMethod(Context, Sel);
+  if (ClassDecl->isForwardDecl()) {
+    // A forward class used in messaging is tread as a 'Class'
+    Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac,rbrac));
+    if (Method)
+      Diag(lbrac, diag::warn_receiver_forward_class) 
+        << ClassDecl->getDeclName();
+  }
+  if (!Method)
+    Method = ClassDecl->lookupClassMethod(Context, Sel);
   
   // If we have an implementation in scope, check "private" methods.
   if (!Method)





More information about the llvm-branch-commits mailing list