summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/null_in_arithmetic_ops.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-10-21 02:36:37 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-10-21 02:36:37 +0000
commit0c1c53e3fad7fadb1c182b3e26e38378d2abe7f8 (patch)
treefb6ebc4ea1222b72b3768ce00b702fe8cc9df890 /clang/test/SemaCXX/null_in_arithmetic_ops.cpp
parent14699cf1c601d2e8f0b6bf6b8e651a14a5a1e42d (diff)
downloadbcm5719-llvm-0c1c53e3fad7fadb1c182b3e26e38378d2abe7f8.tar.gz
bcm5719-llvm-0c1c53e3fad7fadb1c182b3e26e38378d2abe7f8.zip
DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
This has two significant effects: 1) Direct relational comparisons between null pointer constants (0 and nullopt) and pointers are now ill-formed. This was always the case for C, and it appears that C++ only ever permitted by accident. For instance, cases like nullptr < &a are now rejected. 2) Comparisons and conditional operators between differently-cv-qualified pointer types now work, and produce a composite type that both source pointer types can convert to (when possible). For instance, comparison between 'int **' and 'const int **' is now valid, and uses an intermediate type of 'const int *const *'. Clang previously supported #2 as an extension. We do not accept the cases in #1 as an extension. I've tested a fair amount of code to check that this doesn't break it, but if it turns out that someone is relying on this, we can easily add it back as an extension. llvm-svn: 284800
Diffstat (limited to 'clang/test/SemaCXX/null_in_arithmetic_ops.cpp')
-rw-r--r--clang/test/SemaCXX/null_in_arithmetic_ops.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/null_in_arithmetic_ops.cpp b/clang/test/SemaCXX/null_in_arithmetic_ops.cpp
index 3b42ab44feb..ee695ff2420 100644
--- a/clang/test/SemaCXX/null_in_arithmetic_ops.cpp
+++ b/clang/test/SemaCXX/null_in_arithmetic_ops.cpp
@@ -71,8 +71,8 @@ void f() {
b = a == NULL || a != NULL; // expected-warning 2{{comparison between NULL and non-pointer ('int' and NULL)}}
b = NULL == a || NULL != a; // expected-warning 2{{comparison between NULL and non-pointer (NULL and 'int')}}
- b = &a < NULL || NULL < &a || &a > NULL || NULL > &a;
- b = &a <= NULL || NULL <= &a || &a >= NULL || NULL >= &a;
+ b = &a < NULL || NULL < &a || &a > NULL || NULL > &a; // expected-error 4{{ordered comparison between pointer and zero}}
+ b = &a <= NULL || NULL <= &a || &a >= NULL || NULL >= &a; // expected-error 4{{ordered comparison between pointer and zero}}
b = &a == NULL || NULL == &a || &a != NULL || NULL != &a;
b = 0 == a;
OpenPOWER on IntegriCloud