| 1 |
/* |
| 2 |
PERMUTE_ARGS: |
| 3 |
RUN_OUTPUT: |
| 4 |
--- |
| 5 |
count = 3 |
| 6 |
--- |
| 7 |
*/ |
| 8 |
|
| 9 |
// https://issues.dlang.org/show_bug.cgi?id=2311 |
| 10 |
|
| 11 |
extern(C) int printf(const char*, ...); |
| 12 |
|
| 13 |
__gshared ulong count; |
| 14 |
|
| 15 |
shared static ~this() |
| 16 |
{ |
| 17 |
printf("count = %llu\n", count); |
| 18 |
assert(count == 3); |
| 19 |
} |
| 20 |
|
| 21 |
template X(uint idx) |
| 22 |
{ |
| 23 |
static ~this() |
| 24 |
{ |
| 25 |
assert(count == idx); |
| 26 |
++count; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
void main() |
| 31 |
{ |
| 32 |
// Instantiate module destructors in reverse order |
| 33 |
alias x = X!(2); |
| 34 |
alias y = X!(1); |
| 35 |
alias z = X!(0); |
| 36 |
} |