| 1 |
// REQUIRED_ARGS: -de |
| 2 |
/* |
| 3 |
TEST_OUTPUT: |
| 4 |
--- |
| 5 |
fail_compilation/diag3672a.d(17): Error: read-modify-write operations are not allowed for `shared` variables |
| 6 |
fail_compilation/diag3672a.d(17): Use `core.atomic.atomicOp!"+="(ns.x, 1)` instead |
| 7 |
fail_compilation/diag3672a.d(19): Error: read-modify-write operations are not allowed for `shared` variables |
| 8 |
fail_compilation/diag3672a.d(19): Use `core.atomic.atomicOp!"+="(s.sx, 1)` instead |
| 9 |
--- |
| 10 |
*/ |
| 11 |
class NS { shared int x; } |
| 12 |
shared class S { int sx; } |
| 13 |
|
| 14 |
void main() |
| 15 |
{ |
| 16 |
NS ns = new NS; |
| 17 |
ns.x++; |
| 18 |
S s = new S; |
| 19 |
s.sx++; |
| 20 |
} |
| 21 |
|
| 22 |
/* |
| 23 |
TEST_OUTPUT: |
| 24 |
--- |
| 25 |
fail_compilation/diag3672a.d(35): Error: read-modify-write operations are not allowed for `shared` variables |
| 26 |
fail_compilation/diag3672a.d(35): Use `core.atomic.atomicOp!"+="(s.var, 1)` instead |
| 27 |
fail_compilation/diag3672a.d(36): Error: read-modify-write operations are not allowed for `shared` variables |
| 28 |
fail_compilation/diag3672a.d(36): Use `core.atomic.atomicOp!"-="(s.var, 2)` instead |
| 29 |
--- |
| 30 |
*/ |
| 31 |
void test13003() |
| 32 |
{ |
| 33 |
struct S { int var; } |
| 34 |
shared S s; |
| 35 |
s.var++; |
| 36 |
s.var -= 2; |
| 37 |
} |