diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 1f0003e96..271b6626b 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -421,7 +421,7 @@ private: return; } AstNode* arrayp = nodep->arrayp(); // Maybe different node since bracketp looked - if (!VN_IS(arrayp, ParseRef)) { + if (!VN_IS(arrayp, ParseRef) && !VN_IS(arrayp, Dot)) { // Code below needs to use other then attributes to figure out the bounds // Also need to deal with queues, etc arrayp->v3warn(E_UNSUPPORTED, "Unsupported: foreach on non-simple variable reference"); @@ -442,14 +442,11 @@ private: AstNode* varp = new AstVar(fl, AstVarType::BLOCKTEMP, varsp->name(), nodep->findSigned32DType()); // These will be the left and right dimensions and size of the array: - AstNode* leftp = new AstAttrOf(fl, AstAttrType::DIM_LEFT, - new AstVarRef(fl, arrayp->name(), false), + AstNode* leftp = new AstAttrOf(fl, AstAttrType::DIM_LEFT, arrayp->cloneTree(false), new AstConst(fl, dimension)); - AstNode* rightp = new AstAttrOf(fl, AstAttrType::DIM_RIGHT, - new AstVarRef(fl, arrayp->name(), false), + AstNode* rightp = new AstAttrOf(fl, AstAttrType::DIM_RIGHT, arrayp->cloneTree(false), new AstConst(fl, dimension)); - AstNode* sizep = new AstAttrOf(fl, AstAttrType::DIM_SIZE, - new AstVarRef(fl, arrayp->name(), false), + AstNode* sizep = new AstAttrOf(fl, AstAttrType::DIM_SIZE, arrayp->cloneTree(false), new AstConst(fl, dimension)); AstNode* stmtsp = varp; // Assign left-dimension into the loop var: diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 0c12358ec..7ffce2b63 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -116,13 +116,15 @@ static void process() { cout << "--debug-exit-parse: Exiting after parse\n"; exit(0); } + + // Convert parseref's to varrefs, and other directly post parsing fixups + V3LinkParse::linkParse(v3Global.rootp()); if (v3Global.opt.debugExitUvm()) { + V3Error::abortIfErrors(); cout << "--debug-exit-uvm: Exiting after UVM-supported pass\n"; exit(0); } - // Convert parseref's to varrefs, and other directly post parsing fixups - V3LinkParse::linkParse(v3Global.rootp()); // Cross-link signal names // Cross-link dotted hierarchical references V3LinkDot::linkDotPrimary(v3Global.rootp()); diff --git a/test_regress/t/t_foreach_bad.out b/test_regress/t/t_foreach_bad.out index 0a9fed94a..cbb916320 100644 --- a/test_regress/t/t_foreach_bad.out +++ b/test_regress/t/t_foreach_bad.out @@ -1,7 +1,4 @@ %Error: t/t_foreach_bad.v:14:7: Syntax error; foreach missing bracketed index variable (IEEE 1800-2017 12.7.3) 14 | foreach (array); | ^~~~~~~ -%Error-UNSUPPORTED: t/t_foreach_bad.v:16:21: Unsupported: foreach on non-simple variable reference - 16 | foreach (array.array[a]); - | ^ %Error: Exiting due to