Allow comparison between block pointers and NULL pointer

constants. Fixes PR10145.

llvm-svn: 133179
This commit is contained in:
Douglas Gregor 2011-06-16 18:52:05 +00:00
parent 5fc8b77f83
commit 3e85c9c561
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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;