diff options
Diffstat (limited to 'test/SemaCXX/constant-expression-cxx11.cpp')
-rw-r--r-- | test/SemaCXX/constant-expression-cxx11.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp index 3a1f6c6..7b9d015 100644 --- a/test/SemaCXX/constant-expression-cxx11.cpp +++ b/test/SemaCXX/constant-expression-cxx11.cpp @@ -327,7 +327,7 @@ struct Str { }; extern char externalvar[]; -constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}} +constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}} expected-note {{reinterpret_cast}} constexpr bool litaddress = "foo" == "foo"; // expected-error {{must be initialized by a constant expression}} expected-warning {{unspecified}} static_assert(0 != "foo", ""); @@ -1802,8 +1802,8 @@ namespace Bitfields { unsigned u : 5; int n : 5; bool b2 : 3; - unsigned u2 : 74; // expected-warning {{exceeds the size of its type}} - int n2 : 81; // expected-warning {{exceeds the size of its type}} + unsigned u2 : 74; // expected-warning {{exceeds the width of its type}} + int n2 : 81; // expected-warning {{exceeds the width of its type}} }; constexpr A a = { false, 33, 31, false, 0xffffffff, 0x7fffffff }; // expected-warning 2{{truncation}} @@ -1874,10 +1874,9 @@ namespace NeverConstantTwoWays { 0; } - // FIXME: We should diagnose the cast to long here, not the division by zero. constexpr int n = // expected-error {{must be initialized by a constant expression}} - (int *)(long)&n == &n ? - 1 / 0 : // expected-warning {{division by zero}} expected-note {{division by zero}} + (int *)(long)&n == &n ? // expected-note {{reinterpret_cast}} + 1 / 0 : // expected-warning {{division by zero}} 0; } @@ -1994,3 +1993,15 @@ namespace PR17938 { static constexpr auto z = f(Z()); } + +namespace PR24597 { + struct A { + int x, *p; + constexpr A() : x(0), p(&x) {} + constexpr A(const A &a) : x(a.x), p(&x) {} + }; + constexpr A f() { return A(); } + constexpr A g() { return f(); } + constexpr int a = *f().p; + constexpr int b = *g().p; +} |