Fix external function declarations with class typedef references (#6433).

This commit is contained in:
Wilson Snyder 2025-09-14 21:53:13 -04:00
parent 12c524ac06
commit 218af5500b
4 changed files with 55 additions and 0 deletions

View File

@ -46,6 +46,7 @@ Verilator 5.041 devel
* Fix parameter implicit type from string (#6414). [Alex Solomatnikov]
* Fix parsing for sequence expressions (#6427). [Bartłomiej Chmiel, Antmicro Ltd.]
* Fix resolving parameters (#6388) (#6418) (#6421) (#6438) (#6429). [Artur Bieniek, Antmicro Ltd.]
* Fix external function declarations with class typedef references (#6433).
Verilator 5.040 2025-08-30

View File

@ -917,6 +917,14 @@ class LinkDotFindVisitor final : public VNVisitor {
classp->addStmtsp(nodep);
nodep->isExternDef(true); // So we check there's a matching extern
nodep->classOrPackagep()->unlinkFrBack()->deleteTree();
// Any "Type::" reference in the function's IO are really "MovedToClass::" references
if (nodep->fvarp())
nodep->fvarp()->foreach([this, classp](AstClassOrPackageRef* refp) { //
if (refp->name() == classp->name() && !refp->paramsp()) {
UINFO(9, "Cleaning up external function type for class " << refp);
pushDeletep(refp->unlinkFrBack());
}
});
}
}

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,28 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
class uvm_process_guard#(type T=int);
T m_context;
extern function T get_context();
endclass
// When this moves into class, note it's not uvm_process_guard#()::T
// but rather the T specific to the parameterized class
function uvm_process_guard::T uvm_process_guard::get_context();
return this.m_context;
endfunction
class uvm_sequence_base;
typedef uvm_process_guard#(uvm_sequence_base) m_guard_t;
endclass
module t;
initial begin
uvm_sequence_base c;
c = new;
$finish;
end
endmodule