Also allow cast of block pointer type to
pointer to an any object. Another variation of
radar 7562285.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94052 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index e9b6072..7b0c98c 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -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;
 
diff --git a/test/SemaObjCXX/cstyle-block-pointer-cast.mm b/test/SemaObjCXX/cstyle-block-pointer-cast.mm
index 2796512..72f5283 100644
--- a/test/SemaObjCXX/cstyle-block-pointer-cast.mm
+++ b/test/SemaObjCXX/cstyle-block-pointer-cast.mm
@@ -21,3 +21,22 @@
           return (blocktype)c;
 }
 @end
+
+@interface B {
+    blocktype a;
+    blocktype b;
+    blocktype c;
+}
+- (id)Meth;
+@end
+
+@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;
+}
+@end