[cfe-commits] r94052 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaObjCXX/cstyle-block-pointer-cast.mm

Fariborz Jahanian fjahanian at apple.com
Wed Jan 20 16:05:10 PST 2010


Author: fjahanian
Date: Wed Jan 20 18:05:09 2010
New Revision: 94052

URL: http://llvm.org/viewvc/llvm-project?rev=94052&view=rev
Log:
Also allow cast of block pointer type to
pointer to an any object. Another variation of
radar 7562285.


Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaObjCXX/cstyle-block-pointer-cast.mm

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 20 18:05:09 2010
@@ -1151,6 +1151,13 @@
     }
     ToPointeeType = ToBlockPtr->getPointeeType();
   }
+  else if (FromType->getAs<BlockPointerType>() && 
+           ToObjCPtr && ToObjCPtr->isObjCBuiltinType()) {
+    // Objective C++: We're able to convert from a block pointer type to a 
+    // pointer to an any object.
+    ConvertedType = ToType;
+    return true;
+  }
   else
     return false;
 

Modified: cfe/trunk/test/SemaObjCXX/cstyle-block-pointer-cast.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/cstyle-block-pointer-cast.mm?rev=94052&r1=94051&r2=94052&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjCXX/cstyle-block-pointer-cast.mm (original)
+++ cfe/trunk/test/SemaObjCXX/cstyle-block-pointer-cast.mm Wed Jan 20 18:05:09 2010
@@ -21,3 +21,22 @@
           return (blocktype)c;
 }
 @end
+
+ at interface B {
+    blocktype a;
+    blocktype b;
+    blocktype c;
+}
+- (id)Meth;
+ at end
+
+ at implementation B
+- (id)Meth {
+        if (a)
+          return (A*)a; // expected-error {{C-style cast from 'blocktype' (aka 'int (^)(int, int)') to 'A *' is not allowed}}
+        if (b)
+	  return (id)b;
+        if (c)
+	  return (Class)b;
+}
+ at end





More information about the cfe-commits mailing list