Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/systemvariables_struct.d

raw
1 /*
2 REQUIRED_ARGS: -preview=systemVariables
3 TEST_OUTPUT:
4 ---
5 fail_compilation/systemvariables_struct.d(31): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
6 fail_compilation/systemvariables_struct.d(32): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
7 fail_compilation/systemvariables_struct.d(33): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
8 fail_compilation/systemvariables_struct.d(36): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
9 fail_compilation/systemvariables_struct.d(37): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
10 fail_compilation/systemvariables_struct.d(38): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
11 fail_compilation/systemvariables_struct.d(54): Error: accessing `@system` field `S2.syst` is not allowed in a `@safe` function
12 fail_compilation/systemvariables_struct.d(55): Error: accessing `@system` field `S2.syst` is not allowed in a `@safe` function
13 fail_compilation/systemvariables_struct.d(56): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
14 fail_compilation/systemvariables_struct.d(57): Error: accessing `@system` field `S.syst` is not allowed in a `@safe` function
15 ---
16 */
17
18 // http://dlang.org/dips/1035
19
20 struct S
21 {
22 @system S* syst;
23 @safe S* safe;
24 }
25
26 void aggregate() @safe
27 {
28 S s0;
29
30 // write access
31 s0.syst = null;
32 __traits(getMember, s0, "syst") = null;
33 s0.tupleof[0] = null;
34
35 // read access
36 auto a0 = s0.syst;
37 auto a1 = __traits(getMember, s0, "syst");
38 auto a2 = s0.tupleof[0];
39
40 S s1;
41 s1 = s0; // allowed
42 }
43
44 struct S2
45 {
46 @system S syst;
47 @safe S safe;
48 }
49
50 @safe S2 gs2;
51
52 void aggregate2() @safe
53 {
54 gs2.syst.syst = null;
55 gs2.syst.safe = null;
56 gs2.safe.syst = null;
57 gs2.safe.syst.safe = null;
58
59 gs2.safe.safe = null; // allowed
60 }