diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-10-21 02:36:37 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-10-21 02:36:37 +0000 |
commit | 0c1c53e3fad7fadb1c182b3e26e38378d2abe7f8 (patch) | |
tree | fb6ebc4ea1222b72b3768ce00b702fe8cc9df890 /clang/test/SemaCXX/compare.cpp | |
parent | 14699cf1c601d2e8f0b6bf6b8e651a14a5a1e42d (diff) | |
download | bcm5719-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/compare.cpp')
-rw-r--r-- | clang/test/SemaCXX/compare.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/compare.cpp b/clang/test/SemaCXX/compare.cpp index ef0a524f92f..0528b044fb1 100644 --- a/clang/test/SemaCXX/compare.cpp +++ b/clang/test/SemaCXX/compare.cpp @@ -201,9 +201,10 @@ int test1(int i) { enum E { e }; void test2(int i, void *vp) { + if (&i == vp) { } // ok if (test1 == vp) { } // expected-warning{{equality comparison between function pointer and void pointer}} if (test1 == e) { } // expected-error{{comparison between pointer and integer}} - if (vp < 0) { } + if (vp < 0) { } // expected-error {{comparison between pointer and zero}} if (test1 < e) { } // expected-error{{comparison between pointer and integer}} } |