Richard Smith | fde9485 | 2013-09-26 03:33:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++1y -verify %s |
| 2 | |
| 3 | int operator""ms(unsigned long long); // expected-warning {{reserved}} |
| 4 | float operator""ms(long double); // expected-warning {{reserved}} |
| 5 | |
Richard Smith | 7f2707a | 2013-09-26 18:13:20 +0000 | [diff] [blame] | 6 | int operator""_foo(unsigned long long); |
| 7 | |
Richard Smith | fde9485 | 2013-09-26 03:33:06 +0000 | [diff] [blame] | 8 | namespace integral { |
| 9 | static_assert(1'2'3 == 12'3, ""); |
| 10 | static_assert(1'000'000 == 0xf'4240, ""); |
| 11 | static_assert(0'004'000'000 == 0x10'0000, ""); |
| 12 | static_assert(0b0101'0100 == 0x54, ""); |
| 13 | |
| 14 | int a = 123'; //'; // expected-error {{expected ';'}} |
| 15 | int b = 0'xff; // expected-error {{digit separator cannot appear at end of digit sequence}} expected-error {{suffix 'xff' on integer}} |
| 16 | int c = 0x'ff; // expected-error {{suffix 'x'ff' on integer}} |
| 17 | int d = 0'1234; // ok, octal |
| 18 | int e = 0'b1010; // expected-error {{digit 'b' in octal constant}} |
| 19 | int f = 0b'1010; // expected-error {{invalid digit 'b' in octal}} |
| 20 | int g = 123'ms; // expected-error {{digit separator cannot appear at end of digit sequence}} |
| 21 | |
Richard Smith | 7f2707a | 2013-09-26 18:13:20 +0000 | [diff] [blame] | 22 | int z = 0'123'_foo; //'; // expected-error {{cannot appear at end of digit seq}} |
Richard Smith | fde9485 | 2013-09-26 03:33:06 +0000 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | namespace floating { |
| 26 | static_assert(0'123.456'7 == 123.4567, ""); |
| 27 | static_assert(1e1'0 == 10'000'000'000, ""); |
| 28 | |
| 29 | float a = 1'e1; // expected-error {{digit separator cannot appear at end of digit sequence}} |
| 30 | float b = 1'0e1; |
| 31 | float c = 1.'0e1; // expected-error {{digit separator cannot appear at start of digit sequence}} |
| 32 | float d = 1.0'e1; // expected-error {{digit separator cannot appear at end of digit sequence}} |
| 33 | float e = 1e'1; // expected-error {{digit separator cannot appear at start of digit sequence}} |
| 34 | float f = 1e1'ms; // expected-error {{digit separator cannot appear at end of digit sequence}} |
| 35 | } |
Richard Smith | 7f2707a | 2013-09-26 18:13:20 +0000 | [diff] [blame] | 36 | |
| 37 | #line 123'456 |
| 38 | static_assert(__LINE__ == 123456, ""); |
Richard Smith | 52d0211 | 2013-09-26 18:15:22 +0000 | [diff] [blame^] | 39 | |
| 40 | // x has value 0 in C++11 and 34 in C++1y. |
| 41 | #define M(x, ...) __VA_ARGS__ |
| 42 | constexpr int x = { M(1'2,3'4) }; |
| 43 | static_assert(x == 34, ""); |