Fix param-dependent class typedef linking (#6171)

This commit is contained in:
Igor Zaworski 2025-07-11 03:11:09 +02:00 committed by GitHub
parent 4dc6a31276
commit 4e8a8a0398
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 0 deletions

View File

@ -4471,6 +4471,12 @@ class LinkDotResolveVisitor final : public VNVisitor {
nodep->classOrPackagep(cpackagerefp->classOrPackageSkipp());
if (!VN_IS(nodep->classOrPackagep(), Class)
&& !VN_IS(nodep->classOrPackagep(), Package)) {
if (m_statep->forPrimary()) {
// It may be a type that comes from parameter class that is not
// instantioned yet
iterate(cpackagep);
return;
}
// Likely impossible, as error thrown earlier
cpackagerefp->v3error( // LCOV_EXCL_LINE
"'::' expected to reference a class/package but referenced '"

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2025 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
import vltest_bootstrap
test.scenarios('simulator')
test.compile()
test.execute()
test.passes()

View File

@ -0,0 +1,23 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Antmicro.
// SPDX-License-Identifier: CC0-1.0
class Class1 #(type T);
typedef T::Some_type2 Some_type1;
endclass
class Class2;
typedef int Some_type2;
endclass
module t;
initial begin
int value0 = 7;
Class1#(Class2)::Some_type1 value1 = value0;
int value2 = value1;
$write("*-* All Finished *-*\n");
$finish;
end
endmodule