Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3701 from 9rnsr/fix13003
Issue 13003 - Lack of read-modify-write operation check on shared object field
- Loading branch information
Showing
4 changed files
with
78 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// PERMUTE_ARGS: | ||
// REQUIRED_ARGS: -de | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag3672a.d(16): Deprecation: Read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"+="(ns.x, 1) instead. | ||
fail_compilation/diag3672a.d(18): Deprecation: Read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"+="(s.sx, 1) instead. | ||
--- | ||
*/ | ||
class NS { shared int x; } | ||
shared class S { int sx; } | ||
|
||
void main() | ||
{ | ||
NS ns = new NS; | ||
ns.x++; | ||
S s = new S; | ||
s.sx++; | ||
} | ||
|
||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag3672a.d(32): Deprecation: Read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"+="(s.var, 1) instead. | ||
fail_compilation/diag3672a.d(33): Deprecation: Read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"-="(s.var, 2) instead. | ||
--- | ||
*/ | ||
void test13003() | ||
{ | ||
struct S { int var; } | ||
shared S s; | ||
s.var++; | ||
s.var -= 2; | ||
} |