mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00

* Fix Bugzilla 24707 - error message has bad attribute order * Fix tests * Fix & split error test into 2 lines
46 lines
1,022 B
D
46 lines
1,022 B
D
/*
|
|
REQUIRED_ARGS: -verrors=spec -o-
|
|
TEST_OUTPUT:
|
|
---
|
|
(spec:1) fail_compilation/fail20730b.d-mixin-43(43): Error: C style cast illegal, use `cast(int)mod`
|
|
fail_compilation/fail20730b.d(26): Error: template `atomicOp` is not callable using argument types `!("+=")(shared(uint), int)`
|
|
fail_compilation/fail20730b.d(41): Candidate is: `atomicOp(string op, T, V1)(ref shared T val, V1 mod)`
|
|
with `op = "+=",
|
|
T = uint,
|
|
V1 = int`
|
|
must satisfy the following constraint:
|
|
` __traits(compiles, mixin("(int)mod"))`
|
|
---
|
|
*/
|
|
void test20730()
|
|
{
|
|
auto f = File().byLine;
|
|
}
|
|
|
|
struct File
|
|
{
|
|
shared uint refs;
|
|
|
|
this(this)
|
|
{
|
|
atomicOp!"+="(refs, 1);
|
|
}
|
|
|
|
struct ByLineImpl(Char)
|
|
{
|
|
File file;
|
|
char[] line;
|
|
}
|
|
|
|
auto byLine()
|
|
{
|
|
return ByLineImpl!char();
|
|
}
|
|
}
|
|
|
|
T atomicOp(string op, T, V1)(ref shared T val, V1 mod)
|
|
// C-style cast causes raises a parser error whilst gagged.
|
|
if (__traits(compiles, mixin("(int)mod")))
|
|
{
|
|
return val;
|
|
}
|