Fix 'randomize() with {}' crash

This commit is contained in:
Wilson Snyder 2020-11-26 11:50:50 -05:00
parent a37866ee92
commit d56b923eaa
3 changed files with 13 additions and 26 deletions

View File

@ -1290,11 +1290,13 @@ class LinkDotFindVisitor final : public AstNVisitor {
VL_DO_DANGLING(argp->unlinkFrBackWithNext()->deleteTree(), argp);
}
// Type depends on the method used, let V3Width figure it out later
auto* indexArgRefp = new AstLambdaArgRef(argFl, name + "__DOT__index", true);
auto* valueArgRefp = new AstLambdaArgRef(argFl, name, false);
auto* newp = new AstWith(nodep->fileline(), indexArgRefp, valueArgRefp,
nodep->exprp()->unlinkFrBackWithNext());
funcrefp->addPinsp(newp);
const auto indexArgRefp = new AstLambdaArgRef(argFl, name + "__DOT__index", true);
const auto valueArgRefp = new AstLambdaArgRef(argFl, name, false);
if (nodep->exprp()) { // Else empty expression and pretend no "with"
const auto newp = new AstWith(nodep->fileline(), indexArgRefp, valueArgRefp,
nodep->exprp()->unlinkFrBackWithNext());
funcrefp->addPinsp(newp);
}
nodep->replaceWith(funcrefp->unlinkFrBack());
VL_DO_DANGLING(nodep->deleteTree(), nodep);
}

View File

@ -26,6 +26,12 @@ module t (/*AUTOARG*/);
found = aliases.find with (item == i);
aliases.find with (item == i);
`ifdef VERILATOR
// No expression (e.g. x.randomize() with {})
// Hack until randomize() supported
found = aliases.sort() with {};
`endif
// Unique (array method)
id = 4;
found = aliases.find with (id);

View File

@ -1,21 +0,0 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 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(vlt => 1);
top_filename("t/t_with_unsup.v");
lint(
verilator_flags => ["--bbox-unsup"],
fails => 1,
);
ok(1);
1;