blob: df0c26246161257411b5f7c64f9631defa1b531f [file] [log] [blame]
Richard Smithfde94852013-09-26 03:33:06 +00001// RUN: %clang_cc1 -std=c++1y -verify %s
2
3int operator""ms(unsigned long long); // expected-warning {{reserved}}
4float operator""ms(long double); // expected-warning {{reserved}}
5
Richard Smith7f2707a2013-09-26 18:13:20 +00006int operator""_foo(unsigned long long);
7
Richard Smithfde94852013-09-26 03:33:06 +00008namespace 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}}
Richard Smith35ddad02014-02-28 20:06:02 +000021 int h = 0x1e+1; // expected-error {{invalid suffix '+1' on integer constant}}
22 int i = 0x1'e+1; // ok, 'e+' is not recognized after a digit separator
Richard Smithfde94852013-09-26 03:33:06 +000023
Richard Smith7f2707a2013-09-26 18:13:20 +000024 int z = 0'123'_foo; //'; // expected-error {{cannot appear at end of digit seq}}
Richard Smithfde94852013-09-26 03:33:06 +000025}
26
27namespace floating {
28 static_assert(0'123.456'7 == 123.4567, "");
29 static_assert(1e1'0 == 10'000'000'000, "");
30
31 float a = 1'e1; // expected-error {{digit separator cannot appear at end of digit sequence}}
32 float b = 1'0e1;
33 float c = 1.'0e1; // expected-error {{digit separator cannot appear at start of digit sequence}}
34 float d = 1.0'e1; // expected-error {{digit separator cannot appear at end of digit sequence}}
35 float e = 1e'1; // expected-error {{digit separator cannot appear at start of digit sequence}}
36 float f = 1e1'ms; // expected-error {{digit separator cannot appear at end of digit sequence}}
37}
Richard Smith7f2707a2013-09-26 18:13:20 +000038
39#line 123'456
40static_assert(__LINE__ == 123456, "");
Richard Smith52d02112013-09-26 18:15:22 +000041
42// x has value 0 in C++11 and 34 in C++1y.
43#define M(x, ...) __VA_ARGS__
44constexpr int x = { M(1'2,3'4) };
45static_assert(x == 34, "");