@@ -4519,7 +4519,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
45194519 * shared int gate;
45204520 * enum op = isDestructor ? "-=" : "+=";
45214521 * enum cmp = isDestructor ? 0 : 1;
4522- * if (core.atomic.atomicOp !op(gate, 1) != cmp) return;
4522+ * if (._d_atomicOp !op(gate, 1) != cmp) return;
45234523 * ```
45244524 */
45254525
@@ -4532,12 +4532,9 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
45324532 Expression e;
45334533 if (isShared)
45344534 {
4535- e = doAtomicOp(isDestructor ? " -=" : " +=" , v.ident, IntegerExp.literal! (1 ));
4535+ e = doAtomicOp(isDestructor ? " -=" : " +=" , v.ident, IntegerExp.literal! (1 ), sc );
45364536 if (e is null )
4537- {
4538- .error(sd.loc, " %s `%s` shared static %s within a template require `core.atomic : atomicOp` to be present" , sd.kind, sd.toPrettyChars, what);
45394537 return ;
4540- }
45414538 }
45424539 else
45434540 {
@@ -7362,19 +7359,6 @@ Module loadCoreStdcConfig()
73627359 return loadModuleFromLibrary (core_stdc_config, pkgids, Id.config);
73637360}
73647361
7365- /* ***************************
7366- * A Singleton that loads core.atomic
7367- * Returns:
7368- * Module of core.atomic, null if couldn't find it
7369- */
7370- private Module loadCoreAtomic ()
7371- {
7372- __gshared Module core_atomic;
7373- auto pkgids = new Identifier[1 ];
7374- pkgids[0 ] = Id.core;
7375- return loadModuleFromLibrary (core_atomic, pkgids, Id.atomic);
7376- }
7377-
73787362/* *********************************
73797363 * Load a Module from the library.
73807364 * Params:
@@ -7405,28 +7389,21 @@ extern (D) private static Module loadModuleFromLibrary(ref Module mod, Identifie
74057389}
74067390
74077391// / Do an atomic operation (currently tailored to [shared] static ctors|dtors) needs
7408- private CallExp doAtomicOp (string op, Identifier var, Expression arg)
7392+ private CallExp doAtomicOp (string op, Identifier var, Expression arg, Scope * sc )
74097393{
74107394 assert (op == " -=" || op == " +=" );
74117395
7412- Module mod = loadCoreAtomic();
7413- if (! mod)
7414- return null ; // core.atomic couldn't be loaded
7415-
74167396 const loc = Loc.initial;
74177397
7418- Objects * tiargs = new Objects( 1 );
7419- ( * tiargs)[ 0 ] = new StringExp(loc, op) ;
7398+ if ( ! verifyHookExist(loc, * sc, Id._d_atomicOp, " shared static ctors/dtors " ))
7399+ return null ;
74207400
7421- Expressions* args = new Expressions(2 );
7422- (* args)[0 ] = new IdentifierExp(loc, var);
7423- (* args)[1 ] = arg;
74247401
7425- auto sc = new ScopeExp (loc, mod );
7426- auto dti = new DotTemplateInstanceExp(
7427- loc, sc , Id.atomicOp, tiargs );
7402+ Expression e = new IdentifierExp (loc, Id.empty );
7403+ e = new DotIdExp(loc, e, Id.object);
7404+ auto dti = new DotTemplateInstanceExp( loc, e , Id._d_atomicOp, new Objects( new StringExp(loc, op)) );
74287405
7429- return CallExp.create(loc, dti, args );
7406+ return CallExp.create(loc, dti, new Expressions( new IdentifierExp(loc, var), arg) );
74307407}
74317408
74327409/* **************************************************
0 commit comments