diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 1c016ac8f..adc210e24 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -193,8 +193,8 @@ class InstDeVisitor : public AstNVisitor { // Find all cells with arrays, and convert to non-arrayed private: // STATE - AstRange* m_cellRangep - = nullptr; // Range for arrayed instantiations, nullptr for normal instantiations + // Range for arrayed instantiations, nullptr for normal instantiations + AstRange* m_cellRangep = nullptr; int m_instSelNum = 0; // Current instantiation count 0..N-1 InstDeModVarVisitor m_deModVars; // State of variables for current cell module diff --git a/src/V3Scope.cpp b/src/V3Scope.cpp index 1922c7c80..6195ffc98 100644 --- a/src/V3Scope.cpp +++ b/src/V3Scope.cpp @@ -116,7 +116,8 @@ private: // Now for each child cell, iterate the module this cell points to for (AstNode* cellnextp = nodep->stmtsp(); cellnextp; cellnextp = cellnextp->nextp()) { if (AstCell* cellp = VN_CAST(cellnextp, Cell)) { - VL_RESTORER(m_scopep); + VL_RESTORER(m_scopep); // Protects m_scopep set in called module + // which is "above" in this code, but later in code execution order VL_RESTORER(m_aboveCellp); VL_RESTORER(m_aboveScopep); { @@ -329,9 +330,11 @@ private: // VISITORS virtual void visit(AstScope* nodep) override { // Want to ignore blocks under it - m_scopep = nodep; - iterateChildren(nodep); - m_scopep = nullptr; + VL_RESTORER(m_scopep); + { + m_scopep = nodep; + iterateChildren(nodep); + } } virtual void movedDeleteOrIterate(AstNode* nodep) {