[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Lexer / size_t-literal.cpp
blob3e3e8094b070d5a9725325d9b8b1d5a9ea8068f4
1 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
3 #if 1z != 1
4 #error "z suffix must be recognized by preprocessor"
5 #endif
6 #if 1uz != 1
7 #error "uz suffix must be recognized by preprocessor"
8 #endif
9 #if !(-1z < 0)
10 #error "z suffix must be interpreted as signed"
11 #endif
12 #if !(-1uz > 0)
13 #error "uz suffix must be interpreted as unsigned"
14 #endif
16 void ValidSuffix() {
17 // Decimal literals.
19 auto a1 = 1z;
20 auto a2 = 1Z;
22 auto a3 = 1uz;
23 auto a4 = 1uZ;
24 auto a5 = 1Uz;
25 auto a6 = 1UZ;
27 auto a7 = 1zu;
28 auto a8 = 1Zu;
29 auto a9 = 1zU;
30 auto a10 = 1ZU;
32 auto a11 = 1'2z;
33 auto a12 = 1'2Z;
35 // Hexadecimal literals.
37 auto a1 = 0x1z;
38 auto a2 = 0x1Z;
40 auto a3 = 0x1uz;
41 auto a4 = 0x1uZ;
42 auto a5 = 0x1Uz;
43 auto a6 = 0x1UZ;
45 auto a7 = 0x1zu;
46 auto a8 = 0x1Zu;
47 auto a9 = 0x1zU;
48 auto a10 = 0x1ZU;
50 auto a11 = 0x1'2z;
51 auto a12 = 0x1'2Z;
53 // Binary literals.
55 auto a1 = 0b1z;
56 auto a2 = 0b1Z;
58 auto a3 = 0b1uz;
59 auto a4 = 0b1uZ;
60 auto a5 = 0b1Uz;
61 auto a6 = 0b1UZ;
63 auto a7 = 0b1zu;
64 auto a8 = 0b1Zu;
65 auto a9 = 0b1zU;
66 auto a10 = 0b1ZU;
68 auto a11 = 0b1'1z;
69 auto a12 = 0b1'1Z;
71 // Octal literals.
73 auto a1 = 01z;
74 auto a2 = 01Z;
76 auto a3 = 01uz;
77 auto a4 = 01uZ;
78 auto a5 = 01Uz;
79 auto a6 = 01UZ;
81 auto a7 = 01zu;
82 auto a8 = 01Zu;
83 auto a9 = 01zU;
84 auto a10 = 01ZU;
86 auto a11 = 0'1z;
87 auto a12 = 0'1Z;
91 void InvalidSuffix() {
92 // Long.
94 auto a1 = 1lz; // expected-error {{invalid suffix}}
95 auto a2 = 1lZ; // expected-error {{invalid suffix}}
96 auto a3 = 1Lz; // expected-error {{invalid suffix}}
97 auto a4 = 1LZ; // expected-error {{invalid suffix}}
99 auto a5 = 1zl; // expected-error {{invalid suffix}}
100 auto a6 = 1Zl; // expected-error {{invalid suffix}}
101 auto a7 = 1zL; // expected-error {{invalid suffix}}
102 auto a8 = 1ZL; // expected-error {{invalid suffix}}
104 auto a9 = 1ulz; // expected-error {{invalid suffix}}
105 auto a10 = 1ulZ; // expected-error {{invalid suffix}}
106 auto a11 = 1uLz; // expected-error {{invalid suffix}}
107 auto a12 = 1uLZ; // expected-error {{invalid suffix}}
109 auto a13 = 1uzl; // expected-error {{invalid suffix}}
110 auto a14 = 1uZl; // expected-error {{invalid suffix}}
111 auto a15 = 1uzL; // expected-error {{invalid suffix}}
112 auto a16 = 1uZL; // expected-error {{invalid suffix}}
114 // Long long.
116 auto a1 = 1llz; // expected-error {{invalid suffix}}
117 auto a2 = 1llZ; // expected-error {{invalid suffix}}
118 auto a3 = 1LLz; // expected-error {{invalid suffix}}
119 auto a4 = 1LLZ; // expected-error {{invalid suffix}}
121 auto a5 = 1zll; // expected-error {{invalid suffix}}
122 auto a6 = 1Zll; // expected-error {{invalid suffix}}
123 auto a7 = 1zLL; // expected-error {{invalid suffix}}
124 auto a8 = 1ZLL; // expected-error {{invalid suffix}}
126 auto a9 = 1ullz; // expected-error {{invalid suffix}}
127 auto a10 = 1ullZ; // expected-error {{invalid suffix}}
128 auto a11 = 1uLLz; // expected-error {{invalid suffix}}
129 auto a12 = 1uLLZ; // expected-error {{invalid suffix}}
131 auto a13 = 1uzll; // expected-error {{invalid suffix}}
132 auto a14 = 1uZll; // expected-error {{invalid suffix}}
133 auto a15 = 1uzLL; // expected-error {{invalid suffix}}
134 auto a16 = 1uZLL; // expected-error {{invalid suffix}}
136 // Floating point.
138 auto a1 = 0.1z; // expected-error {{invalid suffix}}
139 auto a2 = 0.1Z; // expected-error {{invalid suffix}}
140 auto a3 = 0.1uz; // expected-error {{invalid suffix}}
141 auto a4 = 0.1uZ; // expected-error {{invalid suffix}}
142 auto a5 = 0.1Uz; // expected-error {{invalid suffix}}
143 auto a6 = 0.1UZ; // expected-error {{invalid suffix}}
144 auto a7 = 0.1zu; // expected-error {{invalid suffix}}
145 auto a8 = 0.1Zu; // expected-error {{invalid suffix}}
146 auto a9 = 0.1zU; // expected-error {{invalid suffix}}
147 auto a10 = 0.1ZU; // expected-error {{invalid suffix}}
149 auto a11 = 0.1fz; // expected-error {{invalid suffix}}
150 auto a12 = 0.1fZ; // expected-error {{invalid suffix}}
151 auto a13 = 0.1fuz; // expected-error {{invalid suffix}}
152 auto a14 = 0.1fuZ; // expected-error {{invalid suffix}}
153 auto a15 = 0.1fUz; // expected-error {{invalid suffix}}
154 auto a16 = 0.1fUZ; // expected-error {{invalid suffix}}
155 auto a17 = 0.1fzu; // expected-error {{invalid suffix}}
156 auto a18 = 0.1fZu; // expected-error {{invalid suffix}}
157 auto a19 = 0.1fzU; // expected-error {{invalid suffix}}
158 auto a110 = 0.1fZU; // expected-error {{invalid suffix}}
160 // Repetitive suffix.
162 auto a1 = 1zz; // expected-error {{invalid suffix}}
163 auto a2 = 1zZ; // expected-error {{invalid suffix}}
164 auto a3 = 1Zz; // expected-error {{invalid suffix}}
165 auto a4 = 1ZZ; // expected-error {{invalid suffix}}