diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 77769d5a7..98ee38a5c 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -578,7 +578,7 @@ class LinkParseVisitor final : public VNVisitor { } else if (VN_IS(bracketp, SelLoopVars)) { // Ok } else { - nodep->v3error("Syntax error; foreach missing bracketed loop variable" + nodep->v3error("Foreach missing bracketed loop variable is no-operation" " (IEEE 1800-2023 12.7.3)"); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); return; diff --git a/src/verilog.y b/src/verilog.y index b3f468ace..82ae0137f 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -6112,6 +6112,7 @@ idArrayedForeach: // IEEE: id + select (under foreach expression) id { $$ = new AstParseRef{$1, VParseRefExp::PX_TEXT, *$1, nullptr, nullptr}; } // // IEEE: id + part_select_range/constant_part_select_range + | idArrayed '[' ']' { $$ = $1; } // Or AstArraySel, don't know yet. | idArrayed '[' expr ']' { $$ = new AstSelBit{$2, $1, $3}; } // Or AstArraySel, don't know yet. | idArrayed '[' constExpr ':' constExpr ']' { $$ = new AstSelExtract{$2, $1, $3, $5}; } // // IEEE: id + indexed_range/constant_indexed_range diff --git a/test_regress/t/t_foreach_bad.out b/test_regress/t/t_foreach_bad.out index 0c2524398..4987c12d9 100644 --- a/test_regress/t/t_foreach_bad.out +++ b/test_regress/t/t_foreach_bad.out @@ -1,8 +1,11 @@ -%Error: t/t_foreach_bad.v:14:7: Syntax error; foreach missing bracketed loop variable (IEEE 1800-2023 12.7.3) +%Error: t/t_foreach_bad.v:14:7: Foreach missing bracketed loop variable is no-operation (IEEE 1800-2023 12.7.3) 14 | foreach (array); | ^~~~~~~ ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. -%Error: t/t_foreach_bad.v:18:23: 'foreach' loop variable expects simple variable name - 18 | foreach (array[a.b]); +%Error: t/t_foreach_bad.v:16:7: Foreach missing bracketed loop variable is no-operation (IEEE 1800-2023 12.7.3) + 16 | foreach (array[]); + | ^~~~~~~ +%Error: t/t_foreach_bad.v:20:23: 'foreach' loop variable expects simple variable name + 20 | foreach (array[a.b]); | ^ %Error: Exiting due to diff --git a/test_regress/t/t_foreach_bad.v b/test_regress/t/t_foreach_bad.v index ac2d7bd68..1226338c9 100644 --- a/test_regress/t/t_foreach_bad.v +++ b/test_regress/t/t_foreach_bad.v @@ -13,6 +13,8 @@ module t (/*AUTOARG*/); initial begin foreach (array); // no index + foreach (array[]); // no index + foreach (array.array[a]); // not supported foreach (array[a.b]); // no index