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

llvm-svn: 56793
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 269db21..b19da68 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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);