diff --git a/src/ddmd/dimport.d b/src/ddmd/dimport.d index bff7c34bec76..42fed347d30e 100644 --- a/src/ddmd/dimport.d +++ b/src/ddmd/dimport.d @@ -292,7 +292,7 @@ extern (C++) final class Import : Dsymbol scopesym.addAccessiblePackage(mod, protection); // d } - mod.semantic(null); + mod.doSemanticPass1(); if (mod.needmoduleinfo) { //printf("module4 %s because of %s\n", sc.module.toChars(), mod.toChars()); @@ -409,7 +409,7 @@ extern (C++) final class Import : Dsymbol //printf("Import::semantic2('%s')\n", toChars()); if (mod) { - mod.semantic2(null); + mod.doSemanticPass2(); if (mod.needmoduleinfo) { //printf("module5 %s because of %s\n", sc.module.toChars(), mod.toChars()); @@ -476,7 +476,7 @@ extern (C++) final class Import : Dsymbol { load(null); mod.importAll(null); - mod.semantic(null); + mod.doSemanticPass1(); } // Forward it to the package/module return pkg.search(loc, ident, flags); diff --git a/src/ddmd/dmodule.d b/src/ddmd/dmodule.d index 87f7c4102368..9951faf0fd7b 100644 --- a/src/ddmd/dmodule.d +++ b/src/ddmd/dmodule.d @@ -112,7 +112,7 @@ extern (C++) const(char)* lookForSourceFile(const(char)** path, const(char)* fil return null; } -// function used to call semantic3 on a module's dependencies +// function used to call doSemanticPass3 on a module's dependencies void semantic3OnDependencies(Module m) { if (!m) @@ -121,7 +121,7 @@ void semantic3OnDependencies(Module m) if (m.semanticRun > PASSsemantic3) return; - m.semantic3(null); + m.doSemanticPass3(); foreach (i; 1 .. m.aimports.dim) semantic3OnDependencies(m.aimports[i]); @@ -246,7 +246,7 @@ extern (C++) class Package : ScopeDsymbol return isAncestorPackageOf(pkg.parent.isPackage()); } - override void semantic(Scope* sc) + override final void semantic(Scope* sc) { if (semanticRun < PASSsemanticdone) semanticRun = PASSsemanticdone; @@ -1047,11 +1047,11 @@ extern (C++) final class Module : Package } // semantic analysis - override void semantic(Scope*) + void doSemanticPass1() { if (semanticRun != PASSinit) return; - //printf("+Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); + //printf("+Module::doSemanticPass1(this = %p, '%s'): parent = %p\n", this, toChars(), parent); semanticRun = PASSsemantic; // Note that modules get their own scope, from scratch. // This is so regardless of where in the syntax a module @@ -1080,13 +1080,13 @@ extern (C++) final class Module : Package sc.pop(); // 2 pops because Scope::createGlobal() created 2 } semanticRun = PASSsemanticdone; - //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); + //printf("-Module::doSemanticPass1(this = %p, '%s'): parent = %p\n", this, toChars(), parent); } // pass 2 semantic analysis - override void semantic2(Scope*) + void doSemanticPass2() { - //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); + //printf("Module::doSemanticPass2('%s'): parent = %p\n", toChars(), parent); if (semanticRun != PASSsemanticdone) // semantic() not completed yet - could be recursive call return; semanticRun = PASSsemantic2; @@ -1108,13 +1108,13 @@ extern (C++) final class Module : Package sc = sc.pop(); sc.pop(); semanticRun = PASSsemantic2done; - //printf("-Module::semantic2('%s'): parent = %p\n", toChars(), parent); + //printf("-Module::doSemanticPass2('%s'): parent = %p\n", toChars(), parent); } // pass 3 semantic analysis - override void semantic3(Scope*) + void doSemanticPass3() { - //printf("Module::semantic3('%s'): parent = %p\n", toChars(), parent); + //printf("Module::doSemanticPass3('%s'): parent = %p\n", toChars(), parent); if (semanticRun != PASSsemantic2done) return; semanticRun = PASSsemantic3; diff --git a/src/ddmd/expression.d b/src/ddmd/expression.d index a152bd35e05a..c19d16a97553 100644 --- a/src/ddmd/expression.d +++ b/src/ddmd/expression.d @@ -14912,7 +14912,7 @@ extern (C++) Module loadStdMath() if (s.mod) { s.mod.importAll(null); - s.mod.semantic(null); + s.mod.doSemanticPass1(); } impStdMath = s; } diff --git a/src/ddmd/mars.d b/src/ddmd/mars.d index ca711ed9a32e..59d815847d88 100644 --- a/src/ddmd/mars.d +++ b/src/ddmd/mars.d @@ -237,9 +237,9 @@ extern (C++) void genCmain(Scope* sc) global.params.verbose = false; m.importedFrom = m; m.importAll(null); - m.semantic(null); - m.semantic2(null); - m.semantic3(null); + m.doSemanticPass1(); + m.doSemanticPass2(); + m.doSemanticPass3(); global.params.verbose = v; entrypoint = m; rootHasMain = sc._module; @@ -1454,8 +1454,8 @@ Language changes listed by -transition=id: { Module m = modules[i]; if (global.params.verbose) - fprintf(global.stdmsg, "semantic %s\n", m.toChars()); - m.semantic(null); + fprintf(global.stdmsg, "doSemanticPass1 %s\n", m.toChars()); + m.doSemanticPass1(); } //if (global.errors) // fatal(); @@ -1476,8 +1476,8 @@ Language changes listed by -transition=id: { Module m = modules[i]; if (global.params.verbose) - fprintf(global.stdmsg, "semantic2 %s\n", m.toChars()); - m.semantic2(null); + fprintf(global.stdmsg, "doSemanticPass2 %s\n", m.toChars()); + m.doSemanticPass2(); } Module.runDeferredSemantic2(); if (global.errors) @@ -1488,8 +1488,8 @@ Language changes listed by -transition=id: { Module m = modules[i]; if (global.params.verbose) - fprintf(global.stdmsg, "semantic3 %s\n", m.toChars()); - m.semantic3(null); + fprintf(global.stdmsg, "doSemanticPass3 %s\n", m.toChars()); + m.doSemanticPass3(); } Module.runDeferredSemantic3(); if (global.errors) diff --git a/src/ddmd/module.h b/src/ddmd/module.h index 780850218259..5fa522d44a49 100644 --- a/src/ddmd/module.h +++ b/src/ddmd/module.h @@ -127,9 +127,9 @@ class Module : public Package bool read(Loc loc); // read file, returns 'true' if succeed, 'false' otherwise. Module *parse(); // syntactic parse void importAll(Scope *sc); - void semantic(Scope *); // semantic analysis - void semantic2(Scope *); // pass 2 semantic analysis - void semantic3(Scope *); // pass 3 semantic analysis + void doSemanticPass1(); // pass 1 semantic analysis + void doSemanticPass2(); // pass 2 semantic analysis + void doSemanticPass3(); // pass 3 semantic analysis int needModuleInfo(); Dsymbol *search(Loc loc, Identifier *ident, int flags = SearchLocalsOnly); bool isPackageAccessible(Package *p, Prot protection, int flags = 0); diff --git a/test/compilable/imports/fwdref2_test17548.d b/test/compilable/imports/fwdref2_test17548.d new file mode 100644 index 000000000000..880270d09086 --- /dev/null +++ b/test/compilable/imports/fwdref2_test17548.d @@ -0,0 +1,8 @@ +module fwdref2_test17548; + +import test17548; + +struct S2 { + void bar(int arg = .test17548.cnst) {} + S1 s; +} diff --git a/test/compilable/test17548.d b/test/compilable/test17548.d new file mode 100644 index 000000000000..67b32d7a3ad9 --- /dev/null +++ b/test/compilable/test17548.d @@ -0,0 +1,12 @@ +// REQUIRED_ARGS: -c + +module test17548; + +struct S1 { + void foo(scope S2 arg) {} + int myField; +} + +enum cnst = 4321; + +import imports.fwdref2_test17548;