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
55
66
77using MaxBitInt = _BitInt (128 );
88#define INT_MIN (~__INT_MAX__)
99
1010constexpr _BitInt (2 ) A = 0;
1111constexpr _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}}
1413static_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}}
1916
2017static_assert (B - 1 == 0 , " " );
2118
@@ -38,10 +35,8 @@ static_assert(BI1 == 3, "");
3835
3936constexpr _BitInt (4 ) MulA = 5;
4037constexpr _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)'}}
4540static_assert (MulA * 5 == 25 , " " );
4641static_assert (-1 * MulB == -7 , " " );
4742
@@ -50,29 +45,21 @@ constexpr _BitInt(4) DivA = 2;
5045constexpr _BitInt (2 ) DivB = 1;
5146static_assert (DivA / DivB == 2 , " " );
5247
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}}
5750
5851constexpr _BitInt (7 ) RemA = 47;
5952constexpr _BitInt (6 ) RemB = 9;
6053static_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}}
6556
6657constexpr _BitInt (32 ) bottom = -1;
6758constexpr _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}}
7663
7764namespace APCast {
7865 constexpr _BitInt (10 ) A = 1;
@@ -91,64 +78,48 @@ typedef __int128 int128_t;
9178typedef unsigned __int128 uint128_t ;
9279static const __uint128_t UINT128_MAX =__uint128_t (__int128_t (-1L ));
9380static_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'}}
9883
9984static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t )1 ;
10085static_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'}}
10588static const __int128_t INT128_MIN = -INT128_MAX - 1 ;
10689
10790
10891namespace PointerArithmeticOverflow {
10992 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}}
11495}
11596
11697namespace i128 {
11798
11899 constexpr int128_t I128_1 = 12 ;
119100 static_assert (I128_1 == 12 , " " );
120101 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}}
125104
126105 static const __uint128_t UINT128_MAX =__uint128_t (__int128_t (-1L ));
127106 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'}}
132109
133110 constexpr uint128_t TooMuch = UINT128_MAX * 2 ;
134111
135112 static const __int128_t INT128_MAX = UINT128_MAX >> (__int128_t )1 ;
136113 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'}}
141116
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}}
146119
147120 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}}
152123 constexpr int128_t Two = (int128_t )1 << 1ul ;
153124 static_assert (Two == 2 , " " );
154125 static_assert (Two, " " );
@@ -214,22 +185,17 @@ namespace i128 {
214185 static_assert (CastTo<long double >(12 ) == 12, "");
215186#endif
216187
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}}
223191
224192 constexpr uint128_t Zero = 0 ;
225193 static_assert ((Zero -1 ) == -1 , " " );
226194 constexpr int128_t Five = 5 ;
227195 static_assert (Five - Zero == Five, " " );
228196
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}}
233199}
234200
235201namespace AddSubOffset {
@@ -245,16 +211,14 @@ namespace Bitfields {
245211 struct S1 {
246212 unsigned _BitInt (128 ) a : 2;
247213 };
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}}
250215 constexpr S1 s12{3 };
251216 static_assert (s12.a == 3 , " " );
252217
253218 struct S2 {
254219 unsigned __int128 a : 2 ;
255220 };
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}}
258222}
259223
260224namespace BitOps {
@@ -275,21 +239,15 @@ namespace IncDec {
275239 int128_t a = INT128_MAX;
276240
277241 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}}
280243 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}}
283245 return a;
284246 }
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}}
293251
294252 constexpr int128_t inc1 (bool Pre) {
295253 int128_t A = 0 ;
0 commit comments