diff options
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx11.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/constexpr-printing.cpp | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index 794932df409..7b9d0150e1e 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/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", ""); @@ -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; } diff --git a/clang/test/SemaCXX/constexpr-printing.cpp b/clang/test/SemaCXX/constexpr-printing.cpp index e545f45d601..7f6a9c6a82f 100644 --- a/clang/test/SemaCXX/constexpr-printing.cpp +++ b/clang/test/SemaCXX/constexpr-printing.cpp @@ -90,10 +90,12 @@ constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234\xffffffff"); // \ constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}} +#define fold(x) (__builtin_constant_p(x) ? (x) : (x)) + typedef decltype(sizeof(int)) LabelDiffTy; constexpr LabelDiffTy mulBy3(LabelDiffTy x) { return x * 3; } // expected-note {{subexpression}} void LabelDiffTest() { - static_assert(mulBy3((LabelDiffTy)&&a-(LabelDiffTy)&&b) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}} + static_assert(mulBy3(fold((LabelDiffTy)&&a-(LabelDiffTy)&&b)) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}} a:b:return; } |