[cfe-commits] r120517 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/call-super-2.m test/SemaObjC/class-method-lookup.m test/SemaObjC/method-lookup-5.m test/SemaObjC/method-lookup.m

Fariborz Jahanian fjahanian at apple.com
Tue Nov 30 17:07:24 PST 2010


Author: fjahanian
Date: Tue Nov 30 19:07:24 2010
New Revision: 120517

URL: http://llvm.org/viewvc/llvm-project?rev=120517&view=rev
Log:
When unknown method is sent to a receiver of
'Class' type, disgnostic should refere to a
class method. Fixes // rdar://8592156

Added:
    cfe/trunk/test/SemaObjC/method-lookup-5.m
Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/test/SemaObjC/call-super-2.m
    cfe/trunk/test/SemaObjC/class-method-lookup.m
    cfe/trunk/test/SemaObjC/method-lookup.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=120517&r1=120516&r2=120517&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Nov 30 19:07:24 2010
@@ -1075,7 +1075,9 @@
   Expr **Args = reinterpret_cast<Expr **>(ArgsIn.release());
   QualType ReturnType;
   ExprValueKind VK = VK_RValue;
-  if (CheckMessageArgumentTypes(Args, NumArgs, Sel, Method, false,
+  bool ClassMessage = (ReceiverType->isObjCClassType() ||
+                       ReceiverType->isObjCQualifiedClassType());
+  if (CheckMessageArgumentTypes(Args, NumArgs, Sel, Method, ClassMessage,
                                 LBracLoc, RBracLoc, ReturnType, VK))
     return ExprError();
   

Modified: cfe/trunk/test/SemaObjC/call-super-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-super-2.m?rev=120517&r1=120516&r2=120517&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/call-super-2.m (original)
+++ cfe/trunk/test/SemaObjC/call-super-2.m Tue Nov 30 19:07:24 2010
@@ -35,7 +35,7 @@
 @implementation Derived
 + (int) class_func1
 {
-   int i = (size_t)[self class_func0];       // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}}
+   int i = (size_t)[self class_func0];       // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}}
    return i + (size_t)[super class_func0];   // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}}
 }
 + (int) class_func2

Modified: cfe/trunk/test/SemaObjC/class-method-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/class-method-lookup.m?rev=120517&r1=120516&r2=120517&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/class-method-lookup.m (original)
+++ cfe/trunk/test/SemaObjC/class-method-lookup.m Tue Nov 30 19:07:24 2010
@@ -20,7 +20,7 @@
     [self rootInstanceMethod];            /* class is searched for an instance method  */
     [MyIntermediate rootInstanceMethod];  /* with the same name.                       */
 
-    [self instanceMethod];// expected-warning {{'-instanceMethod' not found (return type defaults to 'id')}}
+    [self instanceMethod];// expected-warning {{'+instanceMethod' not found (return type defaults to 'id')}}
     [MyDerived instanceMethod];// expected-warning {{'+instanceMethod' not found (return type defaults to 'id')}}
 }
 @end

Added: cfe/trunk/test/SemaObjC/method-lookup-5.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-lookup-5.m?rev=120517&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/method-lookup-5.m (added)
+++ cfe/trunk/test/SemaObjC/method-lookup-5.m Tue Nov 30 19:07:24 2010
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8592156
+
+typedef struct objc_class *Class;
+ at interface A
+-(Class) foo;
+ at end
+
+void f0(A *a) { int x = [[a foo] baz]; } // expected-warning {{method '+baz' not found (return type defaults to 'id')}} \
+					 // expected-warning {{ncompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}

Modified: cfe/trunk/test/SemaObjC/method-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-lookup.m?rev=120517&r1=120516&r2=120517&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-lookup.m (original)
+++ cfe/trunk/test/SemaObjC/method-lookup.m Tue Nov 30 19:07:24 2010
@@ -22,7 +22,7 @@
 static NSMutableArray * recentCompletions = ((void *)0);
 + (float) factorForRecentCompletion:(NSString *) completion
 {
-    for (NSObject<PBXCompletionItem> * item in [self completionItems]) // expected-warning{{method '-completionItems' not found (return type defaults to 'id')}}
+    for (NSObject<PBXCompletionItem> * item in [self completionItems]) // expected-warning{{method '+completionItems' not found (return type defaults to 'id')}}
     {
         if ([item respondsToSelector:@selector(setPriority:)])
         {





More information about the cfe-commits mailing list