gcc/testsuite/gdc.test/compilable/readmodify_structclass.d
raw| 1 | // REQUIRED_ARGS: |
| 2 | shared struct S |
| 3 | { |
| 4 | int x = 0; |
| 5 | |
| 6 | int opUnary(string s)() if (s == "++") |
| 7 | { |
| 8 | import core.atomic : atomicOp; |
| 9 | return atomicOp!"+="(x, 1); |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | shared class C |
| 14 | { |
| 15 | int x = 0; |
| 16 | |
| 17 | int opUnary(string s)() if (s == "++") |
| 18 | { |
| 19 | import core.atomic : atomicOp; |
| 20 | return atomicOp!"+="(x, 1); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | void main() |
| 25 | { |
| 26 | S s; |
| 27 | s++; |
| 28 | shared(C) c = new C(); |
| 29 | c++; |
| 30 | } |