]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gdc.test/fail_compilation/fail3672.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail3672.d
CommitLineData
b4c522fa
IB
1/*
2TEST_OUTPUT:
3---
5fee5ec3
IB
4fail_compilation/fail3672.d(28): Error: read-modify-write operations are not allowed for `shared` variables
5fail_compilation/fail3672.d(28): Use `core.atomic.atomicOp!"+="(*p, 1)` instead
6fail_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
10struct SF // should fail
11{
12 void opOpAssign(string op, T)(T rhs)
13 {
14 }
15}
16
17struct SK // ok
18{
19 void opOpAssign(string op, T)(T rhs) shared
20 {
21 }
22}
23
24void 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}