1 // PR c++/55250 2 // { dg-do compile { target c++14 } } 3 4 #define SA(X) static_assert((X),#X) 5 Test1(int x)6constexpr int Test1(int x) { { enum E { y = 1 }; return x + y; } } 7 Test2(int x)8constexpr int Test2(int x) { { struct T { constexpr operator int() { return 1; } }; return x + T(); } } 9 Test3(int x)10constexpr int Test3(int x) { { typedef enum E { y = 1 } EE; return x + EE::y; } } 11 Test4(int x)12constexpr int Test4(int x) { { typedef struct T { constexpr operator int() { return 1; } } TT; return x + TT(); } } 13 Test5(int x)14constexpr int Test5(int x) { { using EE = enum E { y = 1 }; return x + EE::y; } } 15 Test6(int x)16constexpr int Test6(int x) { { using TT = struct T { constexpr operator int() { return 1; } }; return x + TT(); } } 17 18 SA(Test1(2) == 3); 19 SA(Test2(2) == 3); 20 SA(Test3(2) == 3); 21 SA(Test4(2) == 3); 22 SA(Test5(2) == 3); 23 SA(Test6(2) == 3); 24 25 struct S1 26 { S1S127 constexpr S1() { { enum E { y = 1 }; SA(y == 1); } } 28 }; 29 30 struct S2 31 { S2S232 constexpr S2() { { struct T { constexpr operator int() { return 1; } }; SA(T() == 1); } } 33 }; 34 35 struct S3 36 { S3S337 constexpr S3() { { typedef enum E { y = 1} EE; SA(EE::y == 1); } } 38 }; 39 40 struct S4 41 { S4S442 constexpr S4() { { typedef struct T { constexpr operator int() { return 1; } } TT; SA(TT() == 1); } } 43 }; 44 45 struct S5 46 { S5S547 constexpr S5() { { using EE = enum E { y = 1}; SA(EE::y == 1); } } 48 }; 49 50 struct S6 51 { S6S652 constexpr S6() { { using TT = struct T { constexpr operator int() { return 1; } }; SA(TT() == 1); } } 53 }; 54 55 S1 s1; 56 S2 s2; 57 S3 s3; 58 S4 s4; 59 S5 s5; 60 S6 s6; 61