Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/fail20730b.d

raw
1 /*
2 REQUIRED_ARGS: -verrors=spec -o-
3 TEST_OUTPUT:
4 ---
5 (spec:1) fail_compilation/fail20730b.d-mixin-43(43): Error: C style cast illegal, use `cast(int)mod`
6 fail_compilation/fail20730b.d(26): Error: template `atomicOp` is not callable using argument types `!("+=")(shared(uint), int)`
7 fail_compilation/fail20730b.d(41): Candidate is: `atomicOp(string op, T, V1)(ref shared T val, V1 mod)`
8 with `op = "+=",
9 T = uint,
10 V1 = int`
11 must satisfy the following constraint:
12 ` __traits(compiles, mixin("(int)mod"))`
13 ---
14 */
15 void test20730()
16 {
17 auto f = File().byLine;
18 }
19
20 struct File
21 {
22 shared uint refs;
23
24 this(this)
25 {
26 atomicOp!"+="(refs, 1);
27 }
28
29 struct ByLineImpl(Char)
30 {
31 File file;
32 char[] line;
33 }
34
35 auto byLine()
36 {
37 return ByLineImpl!char();
38 }
39 }
40
41 T atomicOp(string op, T, V1)(ref shared T val, V1 mod)
42 // C-style cast causes raises a parser error whilst gagged.
43 if (__traits(compiles, mixin("(int)mod")))
44 {
45 return val;
46 }