Touchup CheckSingleAssignmentConstraints() and CheckCompareOperands() to check for block pointers.
Added a couple FIXME's wrt PointLikeType. If the author reads this, it would be great to get some background on this class (thanks in advance).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55778 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 37172cb..02169e6 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1578,7 +1578,8 @@
 Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) {
   // C99 6.5.16.1p1: the left operand is a pointer and the right is
   // a null pointer constant.
-  if ((lhsType->isPointerType() || lhsType->isObjCQualifiedIdType()) 
+  if ((lhsType->isPointerType() || lhsType->isObjCQualifiedIdType() ||
+       lhsType->isBlockPointerType()) 
       && rExpr->isNullPointerConstant(Context)) {
     ImpCastExprToType(rExpr, lhsType);
     return Compatible;
@@ -1944,6 +1945,23 @@
     ImpCastExprToType(lex, rType); // promote the integer to pointer
     return Context.IntTy;
   }
+  // Handle block pointers.
+  if (lType->isBlockPointerType() && rType->isIntegerType()) {
+    if (!RHSIsNull)
+      Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
+           lType.getAsString(), rType.getAsString(),
+           lex->getSourceRange(), rex->getSourceRange());
+    ImpCastExprToType(rex, lType); // promote the integer to pointer
+    return Context.IntTy;
+  }
+  if (lType->isIntegerType() && rType->isBlockPointerType()) {
+    if (!LHSIsNull)
+      Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
+           lType.getAsString(), rType.getAsString(),
+           lex->getSourceRange(), rex->getSourceRange());
+    ImpCastExprToType(lex, rType); // promote the integer to pointer
+    return Context.IntTy;
+  }
   return InvalidOperands(loc, lex, rex);
 }