Fix typedef scope resolution for parameterized class aliases (#5977) (#7319)

This commit is contained in:
Nick Brereton 2026-03-24 20:25:40 -04:00 committed by GitHub
parent fd2dfd6982
commit 24918b83be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 72 additions and 0 deletions

View File

@ -5799,6 +5799,12 @@ class LinkDotResolveVisitor final : public VNVisitor {
iterate(cpackagep);
return;
}
// Defer non-typedef references through typedef aliases of parameterized classes.
if (m_statep->forPrimary() && !VN_IS(nodep->backp(), Typedef)
&& isParamedClassRef(cpackagerefp)) {
iterate(cpackagep);
return;
}
if (!cpackagerefp->classOrPackageSkipp()) {
VSymEnt* const foundp = m_statep->resolveClassOrPackage(
m_ds.m_dotSymp, cpackagerefp, true, false, "class/package reference");

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# 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-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.compile(verilator_flags2=["--binary"])
test.execute()
test.passes()

View File

@ -0,0 +1,48 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// 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-FileCopyrightText: 2026 Wilson Snyder
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// issue #5977: class-scoped typedef in parameterized class should resolve when
// referenced through a module typedef alias.
package axi_test;
class axi_ax_beat #(
parameter AW = 32,
parameter IW = 8,
parameter UW = 1
);
rand logic [IW-1:0] ax_id = '0;
rand logic [AW-1:0] ax_addr = '0;
rand logic [UW-1:0] ax_user = '0;
endclass
class axi_driver #(
parameter int AW = 32,
parameter int IW = 8,
parameter int UW = 1
);
typedef axi_ax_beat #(.AW(AW), .IW(IW), .UW(UW)) ax_beat_t;
endclass
endpackage
module t;
typedef axi_test::axi_driver #(
.AW(64), .IW(6), .UW(2)
) drv_t;
initial begin
automatic drv_t::ax_beat_t aw_beat = new;
automatic drv_t::ax_beat_t ar_beat = new;
aw_beat.ax_addr = 64'h1234;
ar_beat.ax_addr = aw_beat.ax_addr + 64'd1;
if (ar_beat.ax_addr != 64'h1235) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule