Allow comparison between block pointers and NULL pointer
constants. Fixes PR10145.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133179 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 5e30e71..76612cd 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -7772,7 +7772,8 @@
     // comparisons of member pointers to null pointer constants.
     if (RHSIsNull &&
         ((lType->isAnyPointerType() || lType->isNullPtrType()) ||
-         (!isRelational && lType->isMemberPointerType()))) {
+         (!isRelational && 
+          (lType->isMemberPointerType() || lType->isBlockPointerType())))) {
       rex = ImpCastExprToType(rex.take(), lType, 
                         lType->isMemberPointerType()
                           ? CK_NullToMemberPointer
@@ -7781,7 +7782,8 @@
     }
     if (LHSIsNull &&
         ((rType->isAnyPointerType() || rType->isNullPtrType()) ||
-         (!isRelational && rType->isMemberPointerType()))) {
+         (!isRelational && 
+          (rType->isMemberPointerType() || rType->isBlockPointerType())))) {
       lex = ImpCastExprToType(lex.take(), rType, 
                         rType->isMemberPointerType()
                           ? CK_NullToMemberPointer
diff --git a/test/SemaObjCXX/nullptr.mm b/test/SemaObjCXX/nullptr.mm
index 4cd5669..4a9d1a0 100644
--- a/test/SemaObjCXX/nullptr.mm
+++ b/test/SemaObjCXX/nullptr.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++0x -fblocks -fsyntax-only -verify %s
 
 @interface A
 @end
@@ -11,3 +11,6 @@
 void assignment(A *a) {
   a = nullptr;
 }
+
+int PR10145a = (void(^)())0 == nullptr;
+int PR10145b = nullptr == (void(^)())0;