diff options
Diffstat (limited to 'test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp')
-rw-r--r-- | test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp index db20ea6426e00..9b1727fd04afe 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp @@ -167,6 +167,20 @@ void shrink_int() { Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}} Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}} + + // Negative -> larger unsigned type. + unsigned long long ll1 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} + unsigned long long ll2 = { 1 }; // OK + unsigned long long ll3 = { s }; // expected-error {{cannot be narrowed from type 'short'}} expected-note {{override}} + unsigned long long ll4 = { us }; // OK + unsigned long long ll5 = { ll }; // expected-error {{cannot be narrowed from type 'long long'}} expected-note {{override}} + Agg<unsigned long long> ll6 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} + Agg<unsigned long long> ll7 = { 18446744073709551615ULL }; // OK + Agg<unsigned long long> ll8 = { __int128(18446744073709551615ULL) + 1 }; // expected-error {{ 18446744073709551616 which cannot be narrowed}} expected-note {{override}} expected-warning {{changes value}} + signed char c = 'x'; + unsigned short usc1 = { c }; // expected-error {{non-constant-expression cannot be narrowed from type 'signed char'}} expected-note {{override}} + unsigned short usc2 = { (signed char)'x' }; // OK + unsigned short usc3 = { (signed char)-1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} } // Be sure that type- and value-dependent expressions in templates get the error |