]> granicus.if.org Git - clang/commitdiff
When unknown method is sent to a receiver of
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 1 Dec 2010 01:07:24 +0000 (01:07 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 1 Dec 2010 01:07:24 +0000 (01:07 +0000)
'Class' type, disgnostic should refere to a
class method. Fixes // rdar://8592156

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

lib/Sema/SemaExprObjC.cpp
test/SemaObjC/call-super-2.m
test/SemaObjC/class-method-lookup.m
test/SemaObjC/method-lookup-5.m [new file with mode: 0644]
test/SemaObjC/method-lookup.m

index 04b88e2bde9110fa81e6674634925c0a1f676a0b..047236b1bde3059212cf8f96a0e0e7baf7d04c82 100644 (file)
@@ -1075,7 +1075,9 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
   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();
   
index 043314d4e1821f694387061c47ddb84ae4627b12..84a625c404ec9559d7a2d037ce6e68f620492fdc 100644 (file)
@@ -35,7 +35,7 @@ id objc_getClass(const char *s);
 @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
index f26d692328a2349f7c59597b33d5f8f3ff8875a7..8c8c21682f1e08b5389052f8a085466e216174f3 100644 (file)
@@ -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
diff --git a/test/SemaObjC/method-lookup-5.m b/test/SemaObjC/method-lookup-5.m
new file mode 100644 (file)
index 0000000..13df218
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8592156
+
+typedef struct objc_class *Class;
+@interface A
+-(Class) foo;
+@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'}}
index e3789584bf59e26ee1d31f553ba4b2556fa85ac6..3091124e66ab39c5ec547e2432d4dc18d4de4930 100644 (file)
@@ -22,7 +22,7 @@ typedef int NSInteger;
 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:)])
         {