| 1 |
/* |
| 2 |
REQUIRED_ARGS: -de |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/test20655.d(26): Deprecation: `@safe` function `g` calling `f1` |
| 6 |
fail_compilation/test20655.d(21): and accessing overlapped field `U.s` with pointers makes it fail to infer `@safe` |
| 7 |
fail_compilation/test20655.d(27): Deprecation: `@safe` function `g` calling `f2` |
| 8 |
fail_compilation/test20655.d(22): and accessing overlapped field `U.s` with pointers makes it fail to infer `@safe` |
| 9 |
fail_compilation/test20655.d(28): Deprecation: `@safe` function `g` calling `f3` |
| 10 |
fail_compilation/test20655.d(25): and accessing overlapped field `U.s` with pointers makes it fail to infer `@safe` |
| 11 |
--- |
| 12 |
*/ |
| 13 |
|
| 14 |
union U |
| 15 |
{ |
| 16 |
string s; |
| 17 |
int x; |
| 18 |
} |
| 19 |
U u; |
| 20 |
|
| 21 |
auto f1() { auto s = u.s; } /* Should be inferred as @system. */ |
| 22 |
void f2()() { auto s = u.s; } /* ditto */ |
| 23 |
void g() @safe |
| 24 |
{ |
| 25 |
void f3() { auto s = u.s; } /* ditto */ |
| 26 |
f1(); /* Should be rejected with error "cannot call @system function". */ |
| 27 |
f2(); /* ditto */ |
| 28 |
f3(); /* ditto */ |
| 29 |
} |