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