aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/null_in_arithmetic_ops.cpp11
-rw-r--r--test/SemaCXX/nullptr_in_arithmetic_ops.cpp14
2 files changed, 22 insertions, 3 deletions
diff --git a/test/SemaCXX/null_in_arithmetic_ops.cpp b/test/SemaCXX/null_in_arithmetic_ops.cpp
index b0303177c2..78c76e7e4c 100644
--- a/test/SemaCXX/null_in_arithmetic_ops.cpp
+++ b/test/SemaCXX/null_in_arithmetic_ops.cpp
@@ -59,6 +59,10 @@ void f() {
b = 0 == a;
b = 0 == &a;
+ b = NULL < NULL || NULL > NULL;
+ b = NULL <= NULL || NULL >= NULL;
+ b = NULL == NULL || NULL != NULL;
+
b = ((NULL)) != a; // expected-warning{{use of NULL in arithmetic operation}}
void (^c)();
@@ -67,4 +71,11 @@ void f() {
class X;
void (X::*d) ();
b = d == NULL || NULL == d || d != NULL || NULL != d;
+
+ extern void e();
+ b = e == NULL || NULL == e || e != NULL || NULL != e;
+
+ int f[2];
+ b = f == NULL || NULL == f || f != NULL || NULL != f;
+ b = "f" == NULL || NULL == "f" || "f" != NULL || NULL != "f";
}
diff --git a/test/SemaCXX/nullptr_in_arithmetic_ops.cpp b/test/SemaCXX/nullptr_in_arithmetic_ops.cpp
index 350d18a13f..e839ed116f 100644
--- a/test/SemaCXX/nullptr_in_arithmetic_ops.cpp
+++ b/test/SemaCXX/nullptr_in_arithmetic_ops.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -fblocks -std=c++0x -verify %s
-void f() {
+void foo() {
int a;
bool b;
@@ -49,8 +49,9 @@ void f() {
b = &a <= nullptr || nullptr <= &a || &a >= nullptr || nullptr >= &a;
b = &a == nullptr || nullptr == &a || &a != nullptr || nullptr != &a;
- b = 0 == a;
- b = 0 == &a;
+ b = nullptr < nullptr || nullptr > nullptr;
+ b = nullptr <= nullptr || nullptr >= nullptr;
+ b = nullptr == nullptr || nullptr != nullptr;
b = ((nullptr)) != a; // expected-error{{invalid operands to binary expression}}
@@ -62,4 +63,11 @@ void f() {
void (X::*d) ();
d = nullptr;
b = d == nullptr || nullptr == d || d != nullptr || nullptr != d;
+
+ extern void e();
+ b = e == nullptr || nullptr == e || e != nullptr || nullptr != e;
+
+ int f[2];
+ b = f == nullptr || nullptr == f || f != nullptr || nullptr != f;
+ b = "f" == nullptr || nullptr == "f" || "f" != nullptr || nullptr != "f";
}