Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail3672.d(29): Error: read-modify-write operations are not allowed for `shared` variables
5 fail_compilation/fail3672.d(29): Use `core.atomic.atomicOp!"+="(*p, 1)` instead
6 fail_compilation/fail3672.d(33): Error: template `opOpAssign` is not callable using argument types `!("+")(int) shared`
7 fail_compilation/fail3672.d(13): Candidate is: `opOpAssign(string op, T)(T rhs)`
8 ---
9 */
10
11 struct SF // should fail
12 {
13 void opOpAssign(string op, T)(T rhs)
14 {
15 }
16 }
17
18 struct SK // ok
19 {
20 void opOpAssign(string op, T)(T rhs) shared
21 {
22 }
23 }
24
25 void main()
26 {
27 shared int x;
28 auto p = &x;
29 *p += 1; // fail
30
31 shared SF sf;
32 auto sfp = &sf;
33 *sfp += 1; // fail
34
35 shared SK sk;
36 auto skp = &sk;
37 sk += 1; // ok
38 *skp += 1; // ok
39 }