1
- // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify %s
2
- // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++20 -verify %s
3
- // RUN: %clang_cc1 -std=c++11 -fms-extensions -verify=ref %s
4
- // RUN: %clang_cc1 -std=c++20 -fms-extensions -verify=ref %s
1
+ // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify=expected,both %s
2
+ // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++20 -verify=expected,both %s
3
+ // RUN: %clang_cc1 -std=c++11 -fms-extensions -verify=ref,both %s
4
+ // RUN: %clang_cc1 -std=c++20 -fms-extensions -verify=ref,both %s
5
5
6
6
7
7
using MaxBitInt = _BitInt(128 );
8
8
#define INT_MIN (~__INT_MAX__)
9
9
10
10
constexpr _BitInt (2 ) A = 0;
11
11
constexpr _BitInt (2 ) B = A + 1;
12
- constexpr _BitInt (2 ) C = B + 1; // expected-warning {{from 2 to -2}} \
13
- // ref-warning {{from 2 to -2}}
12
+ constexpr _BitInt (2 ) C = B + 1; // both-warning {{from 2 to -2}}
14
13
static_assert (C == -2 , " " );
15
- static_assert (C - B == A, " " ); // expected-error {{not an integral constant expression}} \
16
- // expected-note {{value -3 is outside the range of representable values}} \
17
- // ref-error {{not an integral constant expression}} \
18
- // ref-note {{value -3 is outside the range of representable values}}
14
+ static_assert (C - B == A, " " ); // both-error {{not an integral constant expression}} \
15
+ // both-note {{value -3 is outside the range of representable values}}
19
16
20
17
static_assert (B - 1 == 0 , " " );
21
18
@@ -38,10 +35,8 @@ static_assert(BI1 == 3, "");
38
35
39
36
constexpr _BitInt (4 ) MulA = 5;
40
37
constexpr _BitInt (4 ) MulB = 7;
41
- static_assert (MulA * MulB == 50 , " " ); // ref-error {{not an integral constant expression}} \
42
- // ref-note {{value 35 is outside the range of representable values of type '_BitInt(4)'}} \
43
- // expected-error {{not an integral constant expression}} \
44
- // expected-note {{value 35 is outside the range of representable values of type '_BitInt(4)'}}
38
+ static_assert (MulA * MulB == 50 , " " ); // both-error {{not an integral constant expression}} \
39
+ // both-note {{value 35 is outside the range of representable values of type '_BitInt(4)'}}
45
40
static_assert (MulA * 5 == 25 , " " );
46
41
static_assert (-1 * MulB == -7 , " " );
47
42
@@ -50,29 +45,21 @@ constexpr _BitInt(4) DivA = 2;
50
45
constexpr _BitInt (2 ) DivB = 1;
51
46
static_assert (DivA / DivB == 2 , " " );
52
47
53
- constexpr _BitInt (4 ) DivC = DivA / 0; // ref-error {{must be initialized by a constant expression}} \
54
- // ref-note {{division by zero}} \
55
- // expected-error {{must be initialized by a constant expression}} \
56
- // expected-note {{division by zero}}
48
+ constexpr _BitInt (4 ) DivC = DivA / 0; // both-error {{must be initialized by a constant expression}} \
49
+ // both-note {{division by zero}}
57
50
58
51
constexpr _BitInt (7 ) RemA = 47;
59
52
constexpr _BitInt (6 ) RemB = 9;
60
53
static_assert (RemA % RemB == 2 , " " );
61
- static_assert (RemA % 0 == 1 , " " ); // ref-error {{not an integral constant expression}} \
62
- // ref-note {{division by zero}} \
63
- // expected-error {{not an integral constant expression}} \
64
- // expected-note {{division by zero}}
54
+ static_assert (RemA % 0 == 1 , " " ); // both-error {{not an integral constant expression}} \
55
+ // both-note {{division by zero}}
65
56
66
57
constexpr _BitInt (32 ) bottom = -1;
67
58
constexpr _BitInt (32 ) top = INT_MIN;
68
- constexpr _BitInt (32 ) nope = top / bottom; // ref-error {{must be initialized by a constant expression}} \
69
- // ref-note {{value 2147483648 is outside the range}} \
70
- // expected-error {{must be initialized by a constant expression}} \
71
- // expected-note {{value 2147483648 is outside the range}}
72
- constexpr _BitInt (32 ) noooo = top % bottom; // ref-error {{must be initialized by a constant expression}} \
73
- // ref-note {{value 2147483648 is outside the range}} \
74
- // expected-error {{must be initialized by a constant expression}} \
75
- // expected-note {{value 2147483648 is outside the range}}
59
+ constexpr _BitInt (32 ) nope = top / bottom; // both-error {{must be initialized by a constant expression}} \
60
+ // both-note {{value 2147483648 is outside the range}}
61
+ constexpr _BitInt (32 ) noooo = top % bottom; // both-error {{must be initialized by a constant expression}} \
62
+ // both-note {{value 2147483648 is outside the range}}
76
63
77
64
namespace APCast {
78
65
constexpr _BitInt (10 ) A = 1;
@@ -91,64 +78,48 @@ typedef __int128 int128_t;
91
78
typedef unsigned __int128 uint128_t ;
92
79
static const __uint128_t UINT128_MAX =__uint128_t (__int128_t (-1L ));
93
80
static_assert (UINT128_MAX == -1 , " " );
94
- static_assert (UINT128_MAX == 1 , " " ); // expected-error {{static assertion failed}} \
95
- // expected-note {{'340282366920938463463374607431768211455 == 1'}} \
96
- // ref-error {{static assertion failed}} \
97
- // ref-note {{'340282366920938463463374607431768211455 == 1'}}
81
+ static_assert (UINT128_MAX == 1 , " " ); // both-error {{static assertion failed}} \
82
+ // both-note {{'340282366920938463463374607431768211455 == 1'}}
98
83
99
84
static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t )1 ;
100
85
static_assert (INT128_MAX != 0 , " " );
101
- static_assert (INT128_MAX == 0 , " " ); // expected-error {{failed}} \
102
- // expected-note {{evaluates to '170141183460469231731687303715884105727 == 0'}} \
103
- // ref-error {{failed}} \
104
- // ref-note {{evaluates to '170141183460469231731687303715884105727 == 0'}}
86
+ static_assert (INT128_MAX == 0 , " " ); // both-error {{failed}} \
87
+ // both-note {{evaluates to '170141183460469231731687303715884105727 == 0'}}
105
88
static const __int128_t INT128_MIN = -INT128_MAX - 1 ;
106
89
107
90
108
91
namespace PointerArithmeticOverflow {
109
92
int n;
110
- constexpr int *p = (&n + 1 ) + (unsigned __int128)-1 ; // expected-error {{constant expression}} \
111
- // expected-note {{cannot refer to element 3402}} \
112
- // ref-error {{constant expression}} \
113
- // ref-note {{cannot refer to element 3402}}
93
+ constexpr int *p = (&n + 1 ) + (unsigned __int128)-1 ; // both-error {{constant expression}} \
94
+ // both-note {{cannot refer to element 3402}}
114
95
}
115
96
116
97
namespace i128 {
117
98
118
99
constexpr int128_t I128_1 = 12 ;
119
100
static_assert (I128_1 == 12 , " " );
120
101
static_assert (I128_1 != 10 , " " );
121
- static_assert (I128_1 != 12 , " " ); // expected-error{{failed}} \
122
- // ref-error{{failed}} \
123
- // expected-note{{evaluates to}} \
124
- // ref-note{{evaluates to}}
102
+ static_assert (I128_1 != 12 , " " ); // both-error{{failed}} \
103
+ // both-note{{evaluates to}}
125
104
126
105
static const __uint128_t UINT128_MAX =__uint128_t (__int128_t (-1L ));
127
106
static_assert (UINT128_MAX == -1 , " " );
128
- static_assert (UINT128_MAX == 1 , " " ); // expected-error {{static assertion failed}} \
129
- // expected-note {{'340282366920938463463374607431768211455 == 1'}} \
130
- // ref-error {{static assertion failed}} \
131
- // ref-note {{'340282366920938463463374607431768211455 == 1'}}
107
+ static_assert (UINT128_MAX == 1 , " " ); // both-error {{static assertion failed}} \
108
+ // both-note {{'340282366920938463463374607431768211455 == 1'}}
132
109
133
110
constexpr uint128_t TooMuch = UINT128_MAX * 2 ;
134
111
135
112
static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t )1 ;
136
113
static_assert (INT128_MAX != 0 , " " );
137
- static_assert (INT128_MAX == 0 , " " ); // expected-error {{failed}} \
138
- // expected-note {{evaluates to '170141183460469231731687303715884105727 == 0'}} \
139
- // ref-error {{failed}} \
140
- // ref-note {{evaluates to '170141183460469231731687303715884105727 == 0'}}
114
+ static_assert (INT128_MAX == 0 , " " ); // both-error {{failed}} \
115
+ // both-note {{evaluates to '170141183460469231731687303715884105727 == 0'}}
141
116
142
- constexpr int128_t TooMuch2 = INT128_MAX * INT128_MAX; // ref-error {{must be initialized by a constant expression}} \
143
- // ref-note {{value 28948022309329048855892746252171976962977213799489202546401021394546514198529 is outside the range of representable}} \
144
- // expected-error {{must be initialized by a constant expression}} \
145
- // expected-note {{value 28948022309329048855892746252171976962977213799489202546401021394546514198529 is outside the range of representable}}
117
+ constexpr int128_t TooMuch2 = INT128_MAX * INT128_MAX; // both-error {{must be initialized by a constant expression}} \
118
+ // both-note {{value 28948022309329048855892746252171976962977213799489202546401021394546514198529 is outside the range of representable}}
146
119
147
120
static const __int128_t INT128_MIN = -INT128_MAX - 1 ;
148
- constexpr __int128 A = INT128_MAX + 1 ; // expected-error {{must be initialized by a constant expression}} \
149
- // expected-note {{value 170141183460469231731687303715884105728 is outside the range}} \
150
- // ref-error {{must be initialized by a constant expression}} \
151
- // ref-note {{value 170141183460469231731687303715884105728 is outside the range}}
121
+ constexpr __int128 A = INT128_MAX + 1 ; // both-error {{must be initialized by a constant expression}} \
122
+ // both-note {{value 170141183460469231731687303715884105728 is outside the range}}
152
123
constexpr int128_t Two = (int128_t )1 << 1ul ;
153
124
static_assert (Two == 2 , " " );
154
125
static_assert (Two, " " );
@@ -214,22 +185,17 @@ namespace i128 {
214
185
static_assert (CastTo<long double >(12 ) == 12, "");
215
186
#endif
216
187
217
- constexpr int128_t Error = __LDBL_MAX__; // ref-warning {{implicit conversion of out of range value}} \
218
- // ref-error {{must be initialized by a constant expression}} \
219
- // ref-note {{is outside the range of representable values of type}} \
220
- // expected-warning {{implicit conversion of out of range value}} \
221
- // expected-error {{must be initialized by a constant expression}} \
222
- // expected-note {{is outside the range of representable values of type}}
188
+ constexpr int128_t Error = __LDBL_MAX__; // both-warning {{implicit conversion of out of range value}} \
189
+ // both-error {{must be initialized by a constant expression}} \
190
+ // both-note {{is outside the range of representable values of type}}
223
191
224
192
constexpr uint128_t Zero = 0 ;
225
193
static_assert ((Zero -1 ) == -1 , " " );
226
194
constexpr int128_t Five = 5 ;
227
195
static_assert (Five - Zero == Five, " " );
228
196
229
- constexpr int128_t Sub1 = INT128_MIN - 1 ; // expected-error {{must be initialized by a constant expression}} \
230
- // expected-note {{-170141183460469231731687303715884105729 is outside the range}} \
231
- // ref-error {{must be initialized by a constant expression}} \
232
- // ref-note {{-170141183460469231731687303715884105729 is outside the range}}
197
+ constexpr int128_t Sub1 = INT128_MIN - 1 ; // both-error {{must be initialized by a constant expression}} \
198
+ // both-note {{-170141183460469231731687303715884105729 is outside the range}}
233
199
}
234
200
235
201
namespace AddSubOffset {
@@ -245,16 +211,14 @@ namespace Bitfields {
245
211
struct S1 {
246
212
unsigned _BitInt (128 ) a : 2;
247
213
};
248
- constexpr S1 s1{100 }; // ref-warning {{changes value from 100 to 0}} \
249
- // expected-warning {{changes value from 100 to 0}}
214
+ constexpr S1 s1{100 }; // both-warning {{changes value from 100 to 0}}
250
215
constexpr S1 s12{3 };
251
216
static_assert (s12.a == 3 , " " );
252
217
253
218
struct S2 {
254
219
unsigned __int128 a : 2 ;
255
220
};
256
- constexpr S2 s2{100 }; // ref-warning {{changes value from 100 to 0}} \
257
- // expected-warning {{changes value from 100 to 0}}
221
+ constexpr S2 s2{100 }; // both-warning {{changes value from 100 to 0}}
258
222
}
259
223
260
224
namespace BitOps {
@@ -275,21 +239,15 @@ namespace IncDec {
275
239
int128_t a = INT128_MAX;
276
240
277
241
if (Pre)
278
- ++a; // ref-note {{value 170141183460469231731687303715884105728 is outside the range}} \
279
- // expected-note {{value 170141183460469231731687303715884105728 is outside the range}}
242
+ ++a; // both-note {{value 170141183460469231731687303715884105728 is outside the range}}
280
243
else
281
- a++; // ref-note {{value 170141183460469231731687303715884105728 is outside the range}} \
282
- // expected-note {{value 170141183460469231731687303715884105728 is outside the range}}
244
+ a++; // both-note {{value 170141183460469231731687303715884105728 is outside the range}}
283
245
return a;
284
246
}
285
- static_assert (maxPlus1(true ) == 0, ""); // ref-error {{not an integral constant expression}} \
286
- // ref-note {{in call to}} \
287
- // expected-error {{not an integral constant expression}} \
288
- // expected-note {{in call to}}
289
- static_assert (maxPlus1(false ) == 0, ""); // ref-error {{not an integral constant expression}} \
290
- // ref-note {{in call to}} \
291
- // expected-error {{not an integral constant expression}} \
292
- // expected-note {{in call to}}
247
+ static_assert (maxPlus1(true ) == 0, ""); // both-error {{not an integral constant expression}} \
248
+ // both-note {{in call to}}
249
+ static_assert (maxPlus1(false ) == 0, ""); // both-error {{not an integral constant expression}} \
250
+ // both-note {{in call to}}
293
251
294
252
constexpr int128_t inc1 (bool Pre) {
295
253
int128_t A = 0 ;
0 commit comments