mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
Fix bugzilla issue 24846 - atomicLoad does not work for class arguments with -preview=nosharedaccess
This commit is contained in:
parent
b11b3f3bfa
commit
a7c85ec3be
4 changed files with 28 additions and 0 deletions
|
@ -15136,6 +15136,27 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
else if (sc._module.ident == Id.atomic && sc._module.parent !is null)
|
||||
{
|
||||
// Allow core.internal.atomic, it is an compiler implementation for a given platform module.
|
||||
// It is then exposed by other modules such as core.atomic and core.stdc.atomic.
|
||||
// This is available as long as druntime is on the import path and the platform supports that operation.
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=24846
|
||||
|
||||
Package parent = sc._module.parent.isPackage();
|
||||
if (parent !is null)
|
||||
{
|
||||
// This can be easily converted over to apply to core.atomic and core.internal.atomic
|
||||
if (parent.ident == Id.internal)
|
||||
{
|
||||
parent = parent.parent.isPackage();
|
||||
|
||||
if (parent !is null && parent.ident == Id.core && parent.parent is null)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("checkSharedAccess() `%s` returnRef: %d\n", e.toChars(), returnRef);
|
||||
|
||||
|
|
|
@ -8606,6 +8606,7 @@ struct Id final
|
|||
static Identifier* va_start;
|
||||
static Identifier* std;
|
||||
static Identifier* core;
|
||||
static Identifier* internal;
|
||||
static Identifier* config;
|
||||
static Identifier* c_complex_float;
|
||||
static Identifier* c_complex_double;
|
||||
|
|
|
@ -389,6 +389,7 @@ immutable Msgtable[] msgtable =
|
|||
// Builtin functions
|
||||
{ "std" },
|
||||
{ "core" },
|
||||
{ "internal" },
|
||||
{ "config" },
|
||||
{ "c_complex_float" },
|
||||
{ "c_complex_double" },
|
||||
|
|
|
@ -5,9 +5,14 @@ class Foo
|
|||
{
|
||||
}
|
||||
|
||||
shared Foo toLoad;
|
||||
|
||||
void oops()
|
||||
{
|
||||
auto f0 = new shared Foo;
|
||||
auto f1 = new shared Foo;
|
||||
atomicStore(f0, f1);
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=24846
|
||||
shared(Foo) f2 = atomicLoad(toLoad);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue