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