| 1 |
// REQUIRED_ARGS: -o- |
| 2 |
// PERMUTE_ARGS: -w |
| 3 |
|
| 4 |
int foo(Args...)() |
| 5 |
{ |
| 6 |
int x; |
| 7 |
|
| 8 |
foreach (arg; Args) |
| 9 |
{ |
| 10 |
static if(is(arg == int)) |
| 11 |
{ |
| 12 |
return 0; |
| 13 |
} |
| 14 |
static if(is(arg == long)) |
| 15 |
{ |
| 16 |
// fallthrough |
| 17 |
++x; // this statement might be unreachable, but |
| 18 |
// UnrollStatement does not warn that. |
| 19 |
} |
| 20 |
} |
| 21 |
// no return |
| 22 |
} |
| 23 |
|
| 24 |
void main() |
| 25 |
{ |
| 26 |
auto r1 = foo!(int)(); // return |
| 27 |
auto r2 = foo!(int, long)(); // return -> fallthrough (it's unreachable) |
| 28 |
auto r3 = foo!(long, int)(); // fallthough -> return |
| 29 |
static assert(!__traits(compiles, foo!(long)())); // fallthough |
| 30 |
static assert(!__traits(compiles, foo!(long, long)())); // fallthough -> fallthough |
| 31 |
} |