From a4ad255438dbd0f2ff52eef42c2a6578f0d2c2ee Mon Sep 17 00:00:00 2001 From: Alex Zhou <126853855+aexzhou@users.noreply.github.com> Date: Fri, 20 Feb 2026 21:43:22 -0800 Subject: [PATCH] Fix extending class by a typedef (#6679) (#6855) --- docs/CONTRIBUTORS | 1 + src/V3LinkDot.cpp | 17 +++++++++++++++++ test_regress/t/t_class_extends_alias.out | 5 ----- test_regress/t/t_class_extends_alias.py | 6 ++++-- 4 files changed, 22 insertions(+), 7 deletions(-) delete mode 100644 test_regress/t/t_class_extends_alias.out diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index b3e411363..34b80c77f 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -12,6 +12,7 @@ Aidan McNay Aleksander Kiryk Alex Chadwick Alex Solomatnikov +Alex Zhou Aliaksei Chapyzhenka Ameya Vikram Singh Andrea Calabrese diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 2c22bf1a2..404dcec95 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -5381,6 +5381,23 @@ class LinkDotResolveVisitor final : public VNVisitor { refParamp->refDTypep(paramp); nodep->childDTypep(refParamp); nodep->parameterized(true); + } else if (AstTypedef* const typedefp = VN_CAST(foundp->nodep(), Typedef)) { + AstNodeDType* const unwrappedp = typedefp->subDTypep()->skipRefp(); + if (AstClassRefDType* const classRefp = VN_CAST(unwrappedp, ClassRefDType)) { + AstPin* paramsp = cpackagerefp->paramsp(); + if (paramsp) { + paramsp = paramsp->cloneTree(true); + nodep->parameterized(true); + } + nodep->childDTypep(new AstClassRefDType{nodep->fileline(), classRefp->classp(), paramsp}); + iterate(nodep->childDTypep()); + } + else { + nodep->v3warn(E_UNSUPPORTED, + "Unsupported: " << foundp->nodep()->prettyTypeName() + << " in 'class extends'"); + return; + } } else { nodep->v3warn(E_UNSUPPORTED, "Unsupported: " << foundp->nodep()->prettyTypeName() << " in 'class extends'"); diff --git a/test_regress/t/t_class_extends_alias.out b/test_regress/t/t_class_extends_alias.out deleted file mode 100644 index f668ed890..000000000 --- a/test_regress/t/t_class_extends_alias.out +++ /dev/null @@ -1,5 +0,0 @@ -%Error-UNSUPPORTED: t/t_class_extends_alias.v:24:21: Unsupported: TYPEDEF 'foo_t' in 'class extends' - 24 | class bar extends foo_t; - | ^~~~~ - ... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest -%Error: Exiting due to diff --git a/test_regress/t/t_class_extends_alias.py b/test_regress/t/t_class_extends_alias.py index c7d9b21a5..3cc73805c 100755 --- a/test_regress/t/t_class_extends_alias.py +++ b/test_regress/t/t_class_extends_alias.py @@ -9,8 +9,10 @@ import vltest_bootstrap -test.scenarios('linter') +test.scenarios('simulator') -test.lint(fails=True, expect_filename=test.golden_filename) +test.compile() + +test.execute() test.passes()