diff --git a/src/V3Global.cpp b/src/V3Global.cpp index a9300eaf3..82dd6e584 100644 --- a/src/V3Global.cpp +++ b/src/V3Global.cpp @@ -77,14 +77,6 @@ void V3Global::readFiles() { "Cannot find file containing library module: "); } - // Delete the std package if unused - if (!usesStdPackage()) { - if (AstNodeModule* stdp = v3Global.rootp()->stdPackagep()) { - v3Global.rootp()->stdPackagep(nullptr); - VL_DO_DANGLING(stdp->unlinkFrBack()->deleteTree(), stdp); - } - } - // v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("parse.tree")); V3Error::abortIfErrors(); @@ -94,6 +86,16 @@ void V3Global::readFiles() { } } +void V3Global::removeStd() { + // Delete the std package if unused + if (!usesStdPackage()) { + if (AstNodeModule* stdp = v3Global.rootp()->stdPackagep()) { + v3Global.rootp()->stdPackagep(nullptr); + VL_DO_DANGLING(stdp->unlinkFrBack()->deleteTree(), stdp); + } + } +} + string V3Global::debugFilename(const string& nameComment, int newNumber) { ++m_debugFileNumber; if (newNumber) m_debugFileNumber = newNumber; diff --git a/src/V3Global.h b/src/V3Global.h index db6dc04ba..fcb4b7e20 100644 --- a/src/V3Global.h +++ b/src/V3Global.h @@ -135,6 +135,7 @@ public: // METHODS void readFiles(); + void removeStd(); void checkTree() const; static void dumpCheckGlobalTree(const string& stagename, int newNumber = 0, bool doDump = true); diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 7ee1fb9e1..65acb5a6f 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -618,6 +618,7 @@ static void verilate(const string& argString) { // Read first filename v3Global.readFiles(); + v3Global.removeStd(); // Link, etc, if needed if (!v3Global.opt.preprocOnly()) { //