Implement comparisons between nullptr and Objective-C object

pointers. Fixes PR10052.

llvm-svn: 132397
This commit is contained in:
Douglas Gregor
2011-06-01 15:12:24 +00:00
parent fd5ecd0cec
commit 39e9fa938c
2 changed files with 15 additions and 2 deletions

View File

@@ -7536,7 +7536,7 @@ QualType Sema::CheckCompareOperands(ExprResult &lex, ExprResult &rex, SourceLoca
// Comparison of pointers with null pointer constants and equality
// comparisons of member pointers to null pointer constants.
if (RHSIsNull &&
((lType->isPointerType() || lType->isNullPtrType()) ||
((lType->isAnyPointerType() || lType->isNullPtrType()) ||
(!isRelational && lType->isMemberPointerType()))) {
rex = ImpCastExprToType(rex.take(), lType,
lType->isMemberPointerType()
@@ -7545,7 +7545,7 @@ QualType Sema::CheckCompareOperands(ExprResult &lex, ExprResult &rex, SourceLoca
return ResultTy;
}
if (LHSIsNull &&
((rType->isPointerType() || rType->isNullPtrType()) ||
((rType->isAnyPointerType() || rType->isNullPtrType()) ||
(!isRelational && rType->isMemberPointerType()))) {
lex = ImpCastExprToType(lex.take(), rType,
rType->isMemberPointerType()

View File

@@ -0,0 +1,13 @@
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
@interface A
@end
void comparisons(A *a) {
(void)(a == nullptr);
(void)(nullptr == a);
}
void assignment(A *a) {
a = nullptr;
}