summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg/pr89017.d
blob: b796e6246e8e7ac040af1625fbab78eaf0baec12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89017
// { dg-do compile }

enum Type
{
    Struct,
    Class,
    Pointer,
    Array,
}

auto f89017(Type type)()
{
    static if (type == Type.Class)
    {
        class C(S)
        {
            struct S
            {
                void fn(){}
            }
        }
    }
    else
    {
        struct C(S)
        {
            struct S
            {
                void fn(){}
            }
        }
    }

    static if (type == Type.Struct)
        return C!Type();
    static if (type == Type.Class || type == Type.Pointer)
        return new C!Type();
    static if (type == Type.Array)
        return new C!Type[2];
}

void test89017()
{
    f89017!(Type.Class);
    f89017!(Type.Struct);
    f89017!(Type.Pointer);
    f89017!(Type.Array);
}