aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExpr.cpp4
-rw-r--r--test/SemaObjCXX/nullptr.mm13
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index e75af910bd..9afd5f8ccd 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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()
diff --git a/test/SemaObjCXX/nullptr.mm b/test/SemaObjCXX/nullptr.mm
new file mode 100644
index 0000000000..4cd5669ef5
--- /dev/null
+++ b/test/SemaObjCXX/nullptr.mm
@@ -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;
+}