mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
Fix Issue 20908 - -preview=nosharedaccess requires zero-initializion for aggregates (#15023)
This commit is contained in:
parent
270845e426
commit
ec07137001
2 changed files with 40 additions and 20 deletions
|
@ -13375,6 +13375,12 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
|
||||||
|
|
||||||
bool visitVar(VarExp e)
|
bool visitVar(VarExp e)
|
||||||
{
|
{
|
||||||
|
// https://issues.dlang.org/show_bug.cgi?id=20908
|
||||||
|
// direct access to init symbols is ok as they
|
||||||
|
// cannot be modified.
|
||||||
|
if (e.var.isSymbolDeclaration())
|
||||||
|
return false;
|
||||||
|
|
||||||
// https://issues.dlang.org/show_bug.cgi?id=22626
|
// https://issues.dlang.org/show_bug.cgi?id=22626
|
||||||
// Synchronized functions don't need to use core.atomic
|
// Synchronized functions don't need to use core.atomic
|
||||||
// when accessing `this`.
|
// when accessing `this`.
|
||||||
|
|
|
@ -11,6 +11,17 @@ ref shared(int) f(return shared ref int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://issues.dlang.org/show_bug.cgi?id=20908
|
// https://issues.dlang.org/show_bug.cgi?id=20908
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
int i = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
union U
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
bool b;
|
||||||
|
}
|
||||||
|
|
||||||
void test20908()
|
void test20908()
|
||||||
{
|
{
|
||||||
// shared locals (or struct members) should be able to be initialised:
|
// shared locals (or struct members) should be able to be initialised:
|
||||||
|
@ -39,6 +50,9 @@ void test20908()
|
||||||
// Multiple indirections
|
// Multiple indirections
|
||||||
return ***val;
|
return ***val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shared S s;
|
||||||
|
shared U u;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple tests for `DotVarExp`
|
// Simple tests for `DotVarExp`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue