@@ -2460,52 +2460,62 @@ E2 testDefaultArgForParam(E2 e2Param = (E2)-1) { // ok, not a constant expressio
2460
2460
void testValueInRangeOfEnumerationValues () {
2461
2461
constexpr E1 x1 = static_cast <E1 >(-8 );
2462
2462
constexpr E1 x2 = static_cast <E1 >(8 );
2463
- // expected-error@-1 {{integer value 8 is outside the valid range of values [-8, 7] for the enumeration type 'E1'}}
2463
+ // expected-error@-1 {{constexpr variable 'x2' must be initialized by a constant expression}}
2464
+ // expected-note@-2 {{integer value 8 is outside the valid range of values [-8, 7] for the enumeration type 'E1'}}
2464
2465
E1 x2b = static_cast <E1 >(8 ); // ok, not a constant expression context
2465
2466
2466
2467
constexpr E2 x3 = static_cast <E2 >(-8 );
2467
- // expected-error@-1 {{integer value -8 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
2468
+ // expected-error@-1 {{constexpr variable 'x3' must be initialized by a constant expression}}
2469
+ // expected-note@-2 {{integer value -8 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
2468
2470
constexpr E2 x4 = static_cast <E2 >(0 );
2469
2471
constexpr E2 x5 = static_cast <E2 >(8 );
2470
- // expected-error@-1 {{integer value 8 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
2472
+ // expected-error@-1 {{constexpr variable 'x5' must be initialized by a constant expression}}
2473
+ // expected-note@-2 {{integer value 8 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
2471
2474
2472
2475
constexpr E3 x6 = static_cast <E3 >(-2048 );
2473
2476
constexpr E3 x7 = static_cast <E3 >(-8 );
2474
2477
constexpr E3 x8 = static_cast <E3 >(0 );
2475
2478
constexpr E3 x9 = static_cast <E3 >(8 );
2476
2479
constexpr E3 x10 = static_cast <E3 >(2048 );
2477
- // expected-error@-1 {{integer value 2048 is outside the valid range of values [-2048, 2047] for the enumeration type 'E3'}}
2480
+ // expected-error@-1 {{constexpr variable 'x10' must be initialized by a constant expression}}
2481
+ // expected-note@-2 {{integer value 2048 is outside the valid range of values [-2048, 2047] for the enumeration type 'E3'}}
2478
2482
2479
2483
constexpr E4 x11 = static_cast <E4 >(0 );
2480
2484
constexpr E4 x12 = static_cast <E4 >(1 );
2481
2485
constexpr E4 x13 = static_cast <E4 >(2 );
2482
- // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for the enumeration type 'E4'}}
2486
+ // expected-error@-1 {{constexpr variable 'x13' must be initialized by a constant expression}}
2487
+ // expected-note@-2 {{integer value 2 is outside the valid range of values [0, 1] for the enumeration type 'E4'}}
2483
2488
2484
2489
constexpr EEmpty x14 = static_cast <EEmpty>(0 );
2485
2490
constexpr EEmpty x15 = static_cast <EEmpty>(1 );
2486
2491
constexpr EEmpty x16 = static_cast <EEmpty>(2 );
2487
- // expected-error@-1 {{integer value 2 is outside the valid range of values [0, 1] for the enumeration type 'EEmpty'}}
2492
+ // expected-error@-1 {{constexpr variable 'x16' must be initialized by a constant expression}}
2493
+ // expected-note@-2 {{integer value 2 is outside the valid range of values [0, 1] for the enumeration type 'EEmpty'}}
2488
2494
2489
2495
constexpr EFixed x17 = static_cast <EFixed>(100 );
2490
2496
constexpr EScoped x18 = static_cast <EScoped>(100 );
2491
2497
2492
2498
constexpr EMaxInt x19 = static_cast <EMaxInt>(__INT_MAX__-1 );
2493
2499
constexpr EMaxInt x20 = static_cast <EMaxInt>((long )__INT_MAX__+1 );
2494
- // expected-error@-1 {{integer value 2147483648 is outside the valid range of values [-2147483648, 2147483647] for the enumeration type 'EMaxInt'}}
2500
+ // expected-error@-1 {{constexpr variable 'x20' must be initialized by a constant expression}}
2501
+ // expected-note@-2 {{integer value 2147483648 is outside the valid range of values [-2147483648, 2147483647] for the enumeration type 'EMaxInt'}}
2495
2502
2496
2503
const NumberType neg_one = (NumberType) ((NumberType) 0 - (NumberType) 1 ); // ok, not a constant expression context
2497
2504
2498
2505
CONSTEXPR_CAST_TO_SYSTEM_ENUM_OUTSIDE_OF_RANGE;
2499
- // expected-error@-1 {{integer value 123 is outside the valid range of values [0, 1] for the enumeration type 'SystemEnum'}}
2506
+ // expected-error@-1 {{constexpr variable 'system_enum' must be initialized by a constant expression}}
2507
+ // expected-note@-2 {{integer value 123 is outside the valid range of values [0, 1] for the enumeration type 'SystemEnum'}}
2500
2508
}
2501
2509
2502
2510
template <class T , unsigned size> struct Bitfield {
2503
- static constexpr T max = static_cast <T>((1 << size) - 1 ); // #enum
2511
+ static constexpr T max = static_cast <T>((1 << size) - 1 );
2512
+ // cxx11-error@-1 {{constexpr variable 'max' must be initialized by a constant expression}}
2513
+ // cxx11-note@-2 {{integer value 15 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
2504
2514
};
2505
2515
2506
2516
void testValueInRangeOfEnumerationValuesViaTemplate () {
2507
2517
Bitfield<E2 , 3 > good;
2508
- Bitfield<E2 , 4 > bad; // cxx11-error@#enum {{integer value 15 is outside the valid range of values [0, 7] for the enumeration type 'E2' }}
2518
+ Bitfield<E2 , 4 > bad; // cxx11-note {{in instantiation }}
2509
2519
}
2510
2520
2511
2521
enum SortOrder {
@@ -2526,4 +2536,5 @@ void A::f(SortOrder order) {
2526
2536
GH50055::E2 GlobalInitNotCE1 = (GH50055::E2 )-1 ; // ok, not a constant expression context
2527
2537
GH50055::E2 GlobalInitNotCE2 = GH50055::testDefaultArgForParam(); // ok, not a constant expression context
2528
2538
constexpr GH50055::E2 GlobalInitCE = (GH50055::E2 )-1 ;
2529
- // expected-error@-1 {{integer value -1 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
2539
+ // expected-error@-1 {{constexpr variable 'GlobalInitCE' must be initialized by a constant expression}}
2540
+ // expected-note@-2 {{integer value -1 is outside the valid range of values [0, 7] for the enumeration type 'E2'}}
0 commit comments