Fix typedefs pointing to parameterized classes (#4747)

* Skip handling of ClassOrPackageRef nodes that point to Typedefs
This commit is contained in:
Ryszard Rozak 2023-12-08 13:13:38 +01:00 committed by GitHub
parent d3142736c8
commit b60117c713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 1 deletions

View File

@ -1150,7 +1150,12 @@ class ParamVisitor final : public VNVisitor {
if (nodep->ifacep()) visitCellOrClassRef(nodep, true);
}
void visit(AstClassRefDType* nodep) override { visitCellOrClassRef(nodep, false); }
void visit(AstClassOrPackageRef* nodep) override { visitCellOrClassRef(nodep, false); }
void visit(AstClassOrPackageRef* nodep) override {
// If it points to a typedef it is not really a class reference. That typedef will be
// visited anyway (from its parent node), so even if it points to a parameterized class
// type, the instance will be created.
if (!VN_IS(nodep->classOrPackageNodep(), Typedef)) visitCellOrClassRef(nodep, false);
}
// Make sure all parameters are constantified
void visit(AstVar* nodep) override {

View File

@ -0,0 +1,21 @@
#!/usr/bin/env perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2022 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(
);
execute(
check_finished => 1,
);
ok(1);
1;

View File

@ -0,0 +1,34 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2023 by Antmicro Ltd.
// SPDX-License-Identifier: CC0-1.0
virtual class Virt;
endclass
class MyInt;
int x;
endclass
class uvm_object_registry #(
type T = Virt
);
static function T create_object();
T obj = new();
obj.x = 1;
return obj;
endfunction
endclass
typedef uvm_object_registry#(MyInt) type_id;
module t;
initial begin
MyInt mi = type_id::create_object();
if (mi.x != 1) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule