Fix error message

This commit is contained in:
Wilson Snyder 2025-07-15 17:41:08 -04:00
parent f3e109d8c5
commit db6b17fdb4
4 changed files with 10 additions and 4 deletions

View File

@ -578,7 +578,7 @@ class LinkParseVisitor final : public VNVisitor {
} else if (VN_IS(bracketp, SelLoopVars)) { } else if (VN_IS(bracketp, SelLoopVars)) {
// Ok // Ok
} else { } 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)"); " (IEEE 1800-2023 12.7.3)");
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
return; return;

View File

@ -6112,6 +6112,7 @@ idArrayedForeach<nodeExprp>: // IEEE: id + select (under foreach expression)
id id
{ $$ = new AstParseRef{$<fl>1, VParseRefExp::PX_TEXT, *$1, nullptr, nullptr}; } { $$ = new AstParseRef{$<fl>1, VParseRefExp::PX_TEXT, *$1, nullptr, nullptr}; }
// // IEEE: id + part_select_range/constant_part_select_range // // 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 '[' expr ']' { $$ = new AstSelBit{$2, $1, $3}; } // Or AstArraySel, don't know yet.
| idArrayed '[' constExpr ':' constExpr ']' { $$ = new AstSelExtract{$2, $1, $3, $5}; } | idArrayed '[' constExpr ':' constExpr ']' { $$ = new AstSelExtract{$2, $1, $3, $5}; }
// // IEEE: id + indexed_range/constant_indexed_range // // IEEE: id + indexed_range/constant_indexed_range

View File

@ -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); 14 | foreach (array);
| ^~~~~~~ | ^~~~~~~
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. ... 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 %Error: t/t_foreach_bad.v:16:7: Foreach missing bracketed loop variable is no-operation (IEEE 1800-2023 12.7.3)
18 | foreach (array[a.b]); 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 %Error: Exiting due to

View File

@ -13,6 +13,8 @@ module t (/*AUTOARG*/);
initial begin initial begin
foreach (array); // no index foreach (array); // no index
foreach (array[]); // no index
foreach (array.array[a]); // not supported foreach (array.array[a]); // not supported
foreach (array[a.b]); // no index foreach (array[a.b]); // no index