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/CXX/expr/expr.const/p2-0x.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/CXX/expr/expr.const/p2-0x.cpp')
-rw-r--r-- | clang/test/CXX/expr/expr.const/p2-0x.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp index fd15960647c..b9927e49c71 100644 --- a/clang/test/CXX/expr/expr.const/p2-0x.cpp +++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp @@ -461,14 +461,14 @@ namespace UnspecifiedRelations { constexpr bool u2 = p > q; // expected-error {{constant expression}} constexpr bool u3 = p <= q; // expected-error {{constant expression}} constexpr bool u4 = p >= q; // expected-error {{constant expression}} - constexpr bool u5 = p < 0; // expected-error {{constant expression}} - constexpr bool u6 = p <= 0; // expected-error {{constant expression}} - constexpr bool u7 = p > 0; // expected-error {{constant expression}} - constexpr bool u8 = p >= 0; // expected-error {{constant expression}} - constexpr bool u9 = 0 < q; // expected-error {{constant expression}} - constexpr bool u10 = 0 <= q; // expected-error {{constant expression}} - constexpr bool u11 = 0 > q; // expected-error {{constant expression}} - constexpr bool u12 = 0 >= q; // expected-error {{constant expression}} + constexpr bool u5 = p < (int*)0; // expected-error {{constant expression}} + constexpr bool u6 = p <= (int*)0; // expected-error {{constant expression}} + constexpr bool u7 = p > (int*)0; // expected-error {{constant expression}} + constexpr bool u8 = p >= (int*)0; // expected-error {{constant expression}} + constexpr bool u9 = (int*)0 < q; // expected-error {{constant expression}} + constexpr bool u10 = (int*)0 <= q; // expected-error {{constant expression}} + constexpr bool u11 = (int*)0 > q; // expected-error {{constant expression}} + constexpr bool u12 = (int*)0 >= q; // expected-error {{constant expression}} void f(), g(); constexpr void (*pf)() = &f, (*pg)() = &g; @@ -522,7 +522,7 @@ namespace UnspecifiedRelations { constexpr void *null = 0; constexpr void *pv = (void*)&s.a; constexpr void *qv = (void*)&s.b; - constexpr bool v1 = null < 0; + constexpr bool v1 = null < (int*)0; constexpr bool v2 = null < pv; // expected-error {{constant expression}} constexpr bool v3 = null == pv; // ok constexpr bool v4 = qv == pv; // ok |