Teach Sema::CheckAssignmentConstraints() to allow assignments between id and block pointer types (^{}).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56793 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 269db21..b19da68 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1653,10 +1653,15 @@
     if (isa<PointerType>(rhsType))
       return CheckPointerTypesForAssignment(lhsType, rhsType);
       
-    if (rhsType->getAsBlockPointerType())
+    if (rhsType->getAsBlockPointerType()) {
       if (lhsType->getAsPointerType()->getPointeeType()->isVoidType())
         return BlockVoidPointer;
-      
+
+      // Treat block pointers as objects.
+      if (getLangOptions().ObjC1 &&
+          lhsType == Context.getCanonicalType(Context.getObjCIdType()))
+        return Compatible;
+    }
     return Incompatible;
   }
 
@@ -1664,6 +1669,11 @@
     if (rhsType->isIntegerType())
       return IntToPointer;
     
+    // Treat block pointers as objects.
+    if (getLangOptions().ObjC1 &&
+        rhsType == Context.getCanonicalType(Context.getObjCIdType()))
+      return Compatible;
+
     if (rhsType->isBlockPointerType())
       return CheckBlockPointerTypesForAssignment(lhsType, rhsType);