[cfe-commits] r56791 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/Sema/block-as-object.m

Steve Naroff snaroff at apple.com
Mon Sep 29 09:51:42 PDT 2008


Author: snaroff
Date: Mon Sep 29 11:51:41 2008
New Revision: 56791

URL: http://llvm.org/viewvc/llvm-project?rev=56791&view=rev
Log:
Fix <rdar://problem/6251012> clang: Blocks are objects too.

Added:
    cfe/trunk/test/Sema/block-as-object.m
Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Sep 29 11:51:41 2008
@@ -281,7 +281,8 @@
     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;

Added: cfe/trunk/test/Sema/block-as-object.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-as-object.m?rev=56791&view=auto

==============================================================================
--- cfe/trunk/test/Sema/block-as-object.m (added)
+++ cfe/trunk/test/Sema/block-as-object.m Mon Sep 29 11:51:41 2008
@@ -0,0 +1,12 @@
+// RUN: clang %s -fsyntax-only -verify
+
+ at interface Whatever
+- copy;
+ at end
+
+typedef long (^MyBlock)(id obj1, id obj2);
+
+void foo(MyBlock b) {
+    id bar = [b copy];
+}
+





More information about the cfe-commits mailing list