d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / test20655.d
blobc3bb70af492882b0f5b0ed7e6734633cbe101c67
1 /*
2 REQUIRED_ARGS: -de
3 TEST_OUTPUT:
4 ---
5 fail_compilation/test20655.d(29): Deprecation: `@safe` function `g` calling `f1`
6 fail_compilation/test20655.d(24): which wouldn't be `@safe` because of:
7 fail_compilation/test20655.d(24): field `U.s` cannot access pointers in `@safe` code that overlap other fields
8 fail_compilation/test20655.d(30): Deprecation: `@safe` function `g` calling `f2`
9 fail_compilation/test20655.d(25): which wouldn't be `@safe` because of:
10 fail_compilation/test20655.d(25): field `U.s` cannot access pointers in `@safe` code that overlap other fields
11 fail_compilation/test20655.d(31): Deprecation: `@safe` function `g` calling `f3`
12 fail_compilation/test20655.d(28): which wouldn't be `@safe` because of:
13 fail_compilation/test20655.d(28): field `U.s` cannot access pointers in `@safe` code that overlap other fields
14 ---
17 union U
19 string s;
20 int x;
22 U u;
24 auto f1() { auto s = u.s; } /* Should be inferred as @system. */
25 void f2()() { auto s = u.s; } /* ditto */
26 void g() @safe
28 void f3() { auto s = u.s; } /* ditto */
29 f1(); /* Should be rejected with error "cannot call @system function". */
30 f2(); /* ditto */
31 f3(); /* ditto */