Skip to content

Commit

Permalink
Merge pull request #6748 from RazvanN7/Fix_Issue_7016
Browse files Browse the repository at this point in the history
Fix Issue 7016 - local import does not create -deps dependency
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
  • Loading branch information
dlang-bot committed May 19, 2017
2 parents a91bc97 + 6be3227 commit afebe0c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ddmd/dmodule.d
Expand Up @@ -112,6 +112,21 @@ extern (C++) const(char)* lookForSourceFile(const(char)** path, const(char)* fil
return null;
}

// function used to call semantic3 on a module's dependencies
void semantic3OnDependencies(Module m)
{
if (!m)
return;

if (m.semanticRun > PASSsemantic3)
return;

m.semantic3(null);

foreach (i; 1 .. m.aimports.dim)
semantic3OnDependencies(m.aimports[i]);
}

enum PKG : int
{
PKGunknown, // not yet determined whether it's a package.d or not
Expand Down
3 changes: 3 additions & 0 deletions src/ddmd/mars.d
Expand Up @@ -1514,6 +1514,9 @@ Language changes listed by -transition=id:
// So deps file generation should be moved after the inlinig stage.
if (global.params.moduleDeps)
{
foreach (i; 1 .. modules[0].aimports.dim)
semantic3OnDependencies(modules[0].aimports[i]);

OutBuffer* ob = global.params.moduleDeps;
if (global.params.moduleDepsFile)
{
Expand Down
7 changes: 7 additions & 0 deletions test/compilable/extra-files/rdeps7016a.d
@@ -0,0 +1,7 @@
module rdeps7016a;

int f()
{
import rdeps7016b;
return i;
}
9 changes: 9 additions & 0 deletions test/compilable/extra-files/rdeps7016b.d
@@ -0,0 +1,9 @@
module rdeps7016b;

int i = 42;

int g()
{
import rdeps7016;
return i;
}
6 changes: 6 additions & 0 deletions test/compilable/extra-files/rdepsOutput.sh
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
grep 'rdeps7016 (.*rdeps7016.d) : private : rdeps7016a' ${RESULTS_DIR}/compilable/rdeps7016.deps || exit 1
grep 'rdeps7016a (.*rdeps7016a.d) : private : rdeps7016b' ${RESULTS_DIR}/compilable/rdeps7016.deps || exit 1
grep 'rdeps7016b (.*rdeps7016b.d) : private : rdeps7016' ${RESULTS_DIR}/compilable/rdeps7016.deps || exit 1
rm -f ${RESULTS_DIR}/compilable/rdeps7016.deps
exit 0
12 changes: 12 additions & 0 deletions test/compilable/rdeps7016.d
@@ -0,0 +1,12 @@
// PERMUTE_ARGS:
// REQUIRED_ARGS: -deps=${RESULTS_DIR}/compilable/rdeps7016.deps
// POST_SCRIPT: compilable/extra-files/rdepsOutput.sh
// EXTRA_SOURCES: extra-files/rdeps7016a.d extra-files/rdeps7016b.d

module rdeps7016;
import rdeps7016a;

void main()
{
f();
}

0 comments on commit afebe0c

Please sign in to comment.