More semantic analysis for blocks...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56064 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 80b33f2..aa8f194 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1296,11 +1296,13 @@
   }
   // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has
   // the type of the other operand."
-  if (lexT->isPointerType() && rex->isNullPointerConstant(Context)) {
+  if ((lexT->isPointerType() || lexT->isBlockPointerType()) &&
+      rex->isNullPointerConstant(Context)) {
     ImpCastExprToType(rex, lexT); // promote the null to a pointer.
     return lexT;
   }
-  if (rexT->isPointerType() && lex->isNullPointerConstant(Context)) {
+  if ((rexT->isPointerType() || rexT->isBlockPointerType()) &&
+      lex->isNullPointerConstant(Context)) {
     ImpCastExprToType(lex, rexT); // promote the null to a pointer.
     return rexT;
   }
@@ -1381,6 +1383,11 @@
       return compositeType;
     }
   }
+  // Selection between block pointer types is ok as long as they are the same.
+  if (lexT->isBlockPointerType() && rexT->isBlockPointerType() &&
+      Context.getCanonicalType(lexT) == Context.getCanonicalType(rexT))
+    return lexT;
+
   // Otherwise, the operands are not compatible.
   Diag(questionLoc, diag::err_typecheck_cond_incompatible_operands,
        lexT.getAsString(), rexT.getAsString(),