mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
Fix Bugzilla 24705 - Arguments of synchronized method are wrongly shared with -preview=nosharedaccess
This commit is contained in:
parent
ae2dc11619
commit
1d2e15ef18
2 changed files with 8 additions and 3 deletions
|
@ -15155,10 +15155,8 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
|
||||||
{
|
{
|
||||||
if (e.var.isThisDeclaration())
|
if (e.var.isThisDeclaration())
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
return sharedError(e);
|
|
||||||
}
|
}
|
||||||
else if (!allowRef && e.var.type.isShared())
|
if (!allowRef && e.var.type.isShared())
|
||||||
return sharedError(e);
|
return sharedError(e);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -20,4 +20,11 @@ class Oops
|
||||||
// this shouldn't compile `k` is a field of class `Oops`
|
// this shouldn't compile `k` is a field of class `Oops`
|
||||||
static assert (!__traits(compiles, k = 2));
|
static assert (!__traits(compiles, k = 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://issues.dlang.org/show_bug.cgi?id=24705
|
||||||
|
synchronized void foo(int n)
|
||||||
|
{
|
||||||
|
// Error: direct access to shared `n` is not allowed, see `core.atomic`
|
||||||
|
int a = n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue