From 16cd4b744ada95eedeca6d90702739f0262309d4 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 16 Jun 2011 18:52:05 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaExpr.cpp | 6 ++++-- test/SemaObjCXX/nullptr.mm | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 5e30e7179c..76612cd6d8 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -7772,7 +7772,8 @@ QualType Sema::CheckCompareOperands(ExprResult &lex, ExprResult &rex, SourceLoca // 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 @@ QualType Sema::CheckCompareOperands(ExprResult &lex, ExprResult &rex, SourceLoca } 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 4cd5669ef5..4a9d1a07de 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 comparisons(A *a) { void assignment(A *a) { a = nullptr; } + +int PR10145a = (void(^)())0 == nullptr; +int PR10145b = nullptr == (void(^)())0; -- 2.40.0