Fix parameterized class function (#6659) (#6802)

This commit is contained in:
em2machine
2025-12-12 04:17:08 -08:00
committed by GitHub
parent 0901c91b45
commit 2995748d46
5 changed files with 133 additions and 2 deletions
+11 -2
View File
@@ -1313,11 +1313,20 @@ class ClassRefUnlinkerVisitor final : public VNVisitor {
public:
explicit ClassRefUnlinkerVisitor(AstNetlist* netlistp) { iterate(netlistp); }
void visit(AstClassOrPackageRef* nodep) override {
if (nodep->paramsp()) {
if (AstClass* const classp = VN_CAST(nodep->classOrPackageSkipp(), Class)) {
if (!classp->user3p()) VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
if (!classp->user3p()) {
// Check if this ClassOrPackageRef is the lhsp of a DOT node
AstDot* const dotp = VN_CAST(nodep->backp(), Dot);
if (dotp && dotp->lhsp() == nodep) {
// Replace DOT with just its rhsp to avoid leaving DOT with null lhsp
dotp->replaceWith(dotp->rhsp()->unlinkFrBack());
VL_DO_DANGLING2(pushDeletep(dotp), dotp, nodep);
} else {
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);
}
}
}
}
}