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

This commit is contained in:
Wilson Snyder 2025-09-14 23:52:48 -04:00
parent 3f7d13b2cf
commit 39a9a00299
2 changed files with 19 additions and 7 deletions

View File

@ -918,15 +918,22 @@ class LinkDotFindVisitor final : public VNVisitor {
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());
}
});
if (nodep->fvarp()) moveExternFuncDeclRefs(nodep->fvarp(), classp);
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (AstVar* const portp = VN_CAST(stmtp, Var)) {
if (portp->isIO()) moveExternFuncDeclRefs(portp, classp);
}
}
}
}
void moveExternFuncDeclRefs(AstNode* nodep, AstClass* classp) {
nodep->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());
}
});
}
// VISITORS
void visit(AstNetlist* nodep) override { // FindVisitor::

View File

@ -7,6 +7,7 @@
class uvm_process_guard#(type T=int);
T m_context;
extern function T get_context();
extern function new(T ctxt);
endclass
// When this moves into class, note it's not uvm_process_guard#()::T
@ -15,6 +16,10 @@ function uvm_process_guard::T uvm_process_guard::get_context();
return this.m_context;
endfunction
function uvm_process_guard::new(uvm_process_guard::T ctxt);
this.m_context = ctxt;
endfunction : new
class uvm_sequence_base;
typedef uvm_process_guard#(uvm_sequence_base) m_guard_t;
endclass