| 1 |
// https://issues.dlang.org/show_bug.cgi?id=21861 |
| 2 |
|
| 3 |
int f() { |
| 4 |
@("S") |
| 5 |
struct S {} |
| 6 |
|
| 7 |
@("U") |
| 8 |
union U {} |
| 9 |
|
| 10 |
@("C") |
| 11 |
class C {} |
| 12 |
|
| 13 |
// OK <- CTFE fails on this: |
| 14 |
@("E") |
| 15 |
enum E { X } |
| 16 |
|
| 17 |
// OK <- CTFE fails on this: |
| 18 |
@("f") |
| 19 |
int f(int x) { return x + 2; } |
| 20 |
|
| 21 |
// OK <- CTFE fails on this: |
| 22 |
@(&f) int a; |
| 23 |
@(1) @(2) int b = 4, c; |
| 24 |
@(3) extern(C) int d = 3; |
| 25 |
|
| 26 |
enum uda1 = __traits(getAttributes, a); |
| 27 |
enum uda2 = __traits(getAttributes, b); |
| 28 |
enum uda3 = __traits(getAttributes, c); |
| 29 |
|
| 30 |
// These are to trigger a compiler assert if parser is updated in the future |
| 31 |
static assert(!__traits(compiles, mixin("{ @(1) { int x; int y; } }"))); |
| 32 |
static assert(!__traits(compiles, mixin("{ @(1): int x; int y; }"))); |
| 33 |
|
| 34 |
// 3+2 1 2 4 1 3 |
| 35 |
return uda1[0](3) + uda2[0] + uda2[1] + b + uda3[0] + d; |
| 36 |
} |
| 37 |
|
| 38 |
static assert(f() == 16); |