Fix foreach unnamedblk duplicate error (#3885).

This commit is contained in:
Wilson Snyder 2023-01-18 21:48:06 -05:00
parent 6a60ace2c7
commit 035bf13e4a
4 changed files with 41 additions and 2 deletions

View File

@ -29,6 +29,7 @@ Verilator 5.005 devel
* Fix memory leak in V3Sched, etc. (#3834). [Geza Lore]
* Fix compatibility with musl libc / Alpine Linux (#3845). [Sören Tempel]
* Fix empty case items crash (#3851). [rporter]
* Fix foreach unnamedblk duplicate error (#3885). [Ilya Barkov]
Verilator 5.004 2022-12-14

View File

@ -1029,8 +1029,13 @@ class LinkDotFindVisitor final : public VNVisitor {
// are common.
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (VN_IS(stmtp, Var) || VN_IS(stmtp, Foreach)) {
++m_modBlockNum;
nodep->name("unnamedblk" + cvtToStr(m_modBlockNum));
std::string name;
do {
++m_modBlockNum;
name = "unnamedblk" + cvtToStr(m_modBlockNum);
// Increment again if earlier pass of V3LinkDot claimed this name
} while (m_curSymp->findIdFlat(name));
nodep->name(name);
break;
}
}

View File

@ -0,0 +1,17 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2023 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(linter => 1);
lint(
);
ok(1);
1;

View File

@ -0,0 +1,16 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2023 by Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
module t;
function void func();
int a[2];
begin
int t;
end
foreach (a[i]) begin
end
endfunction
endmodule