]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6251012> clang: Blocks are objects too.
authorSteve Naroff <snaroff@apple.com>
Mon, 29 Sep 2008 16:51:41 +0000 (16:51 +0000)
committerSteve Naroff <snaroff@apple.com>
Mon, 29 Sep 2008 16:51:41 +0000 (16:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56791 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprObjC.cpp
test/Sema/block-as-object.m [new file with mode: 0644]

index a2a3992bab5908a6035391360e5b67f27212f8f0..db83405283652016d14f049b8b526a795821353b 100644 (file)
@@ -281,7 +281,8 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
     Context.getCanonicalType(RExpr->getType()).getUnqualifiedType();
   
   // Handle messages to id.
-  if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType())) {
+  if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) ||
+      ReceiverCType->getAsBlockPointerType()) {
     ObjCMethodDecl *Method = InstanceMethodPool[Sel].Method;
     if (!Method)
       Method = FactoryMethodPool[Sel].Method;
diff --git a/test/Sema/block-as-object.m b/test/Sema/block-as-object.m
new file mode 100644 (file)
index 0000000..2bfb9c3
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: clang %s -fsyntax-only -verify
+
+@interface Whatever
+- copy;
+@end
+
+typedef long (^MyBlock)(id obj1, id obj2);
+
+void foo(MyBlock b) {
+    id bar = [b copy];
+}
+