Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ddmd/dimport.d
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 11 additions & 11 deletions src/ddmd/dmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ddmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -14912,7 +14912,7 @@ extern (C++) Module loadStdMath()
if (s.mod)
{
s.mod.importAll(null);
s.mod.semantic(null);
s.mod.doSemanticPass1();
}
impStdMath = s;
}
Expand Down
18 changes: 9 additions & 9 deletions src/ddmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/ddmd/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions test/compilable/imports/fwdref2_test17548.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module fwdref2_test17548;

import test17548;

struct S2 {
void bar(int arg = .test17548.cnst) {}
S1 s;
}
12 changes: 12 additions & 0 deletions test/compilable/test17548.d
Original file line number Diff line number Diff line change
@@ -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;