| 1 |
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89017 |
| 2 |
// { dg-do compile } |
| 3 |
|
| 4 |
enum Type |
| 5 |
{ |
| 6 |
Struct, |
| 7 |
Class, |
| 8 |
Pointer, |
| 9 |
Array, |
| 10 |
} |
| 11 |
|
| 12 |
auto f89017(Type type)() |
| 13 |
{ |
| 14 |
static if (type == Type.Class) |
| 15 |
{ |
| 16 |
class C(S) |
| 17 |
{ |
| 18 |
struct S |
| 19 |
{ |
| 20 |
void fn(){} |
| 21 |
} |
| 22 |
} |
| 23 |
} |
| 24 |
else |
| 25 |
{ |
| 26 |
struct C(S) |
| 27 |
{ |
| 28 |
struct S |
| 29 |
{ |
| 30 |
void fn(){} |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
static if (type == Type.Struct) |
| 36 |
return C!Type(); |
| 37 |
static if (type == Type.Class || type == Type.Pointer) |
| 38 |
return new C!Type(); |
| 39 |
static if (type == Type.Array) |
| 40 |
return new C!Type[2]; |
| 41 |
} |
| 42 |
|
| 43 |
void test89017() |
| 44 |
{ |
| 45 |
f89017!(Type.Class); |
| 46 |
f89017!(Type.Struct); |
| 47 |
f89017!(Type.Pointer); |
| 48 |
f89017!(Type.Array); |
| 49 |
} |