Fix fork crash with no init, test for (#4471)

This commit is contained in:
Wilson Snyder 2023-09-10 08:53:21 -04:00
parent cb5466a90b
commit b5b278d072
3 changed files with 47 additions and 4 deletions

View File

@ -218,10 +218,12 @@ private:
beginp->stmtsp()->addNext(instAsgnp);
beginp->stmtsp()->addNext(forkp);
forkp->initsp()->foreach([forkp](AstAssign* asgnp) {
asgnp->unlinkFrBack();
forkp->addHereThisAsNext(asgnp);
});
if (forkp->initsp()) {
forkp->initsp()->foreach([forkp](AstAssign* asgnp) {
asgnp->unlinkFrBack();
forkp->addHereThisAsNext(asgnp);
});
}
UASSERT_OBJ(!forkp->initsp(), forkp, "Leftover nodes in block_item_declaration");
m_modp->addStmtsp(m_instance.m_classp);

View File

@ -0,0 +1,26 @@
#!/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(simulator => 1);
compile(
verilator_flags2 => ["--exe --main --timing"],
make_main => 0,
# bug#4471 - remove this
verilator_make_gmake => 0,
);
#bug#4471 - add this
#execute(
# check_finished => 1,
# );
ok(1);
1;

View File

@ -0,0 +1,15 @@
// 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();
initial fork
reg i;
i = 1'b1;
if (i != 1'b1) $stop;
$write("*-* All Finished *-*\n");
$finish;
join
endmodule