aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/test14747.d
blob: eb0b418933d2bf54b2be91dd52237d9cdcdb83fb (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
// REQUIRED_ARGS: -o-
// PERMUTE_ARGS: -w

int foo(Args...)()
{
    int x;

    foreach (arg; Args)
    {
        static if(is(arg == int))
        {
            return 0;
        }
        static if(is(arg == long))
        {
            // fallthrough
            ++x;    // this statement might be unreachable, but
                    // UnrollStatement does not warn that.
        }
    }
    // no return
}

void main()
{
    auto r1 = foo!(int)();          // return
    auto r2 = foo!(int, long)();    // return -> fallthrough (it's unreachable)
    auto r3 = foo!(long, int)();    // fallthough -> return
    static assert(!__traits(compiles, foo!(long)()));       // fallthough
    static assert(!__traits(compiles, foo!(long, long)())); // fallthough -> fallthough
}