Fix extending class by a typedef (#6679) (#6855)

This commit is contained in:
Alex Zhou 2026-02-20 21:43:22 -08:00 committed by GitHub
parent 0051d91555
commit a4ad255438
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 7 deletions

View File

@ -12,6 +12,7 @@ Aidan McNay
Aleksander Kiryk Aleksander Kiryk
Alex Chadwick Alex Chadwick
Alex Solomatnikov Alex Solomatnikov
Alex Zhou
Aliaksei Chapyzhenka Aliaksei Chapyzhenka
Ameya Vikram Singh Ameya Vikram Singh
Andrea Calabrese Andrea Calabrese

View File

@ -5381,6 +5381,23 @@ class LinkDotResolveVisitor final : public VNVisitor {
refParamp->refDTypep(paramp); refParamp->refDTypep(paramp);
nodep->childDTypep(refParamp); nodep->childDTypep(refParamp);
nodep->parameterized(true); 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 { } else {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: " << foundp->nodep()->prettyTypeName() nodep->v3warn(E_UNSUPPORTED, "Unsupported: " << foundp->nodep()->prettyTypeName()
<< " in 'class extends'"); << " in 'class extends'");

View File

@ -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

View File

@ -9,8 +9,10 @@
import vltest_bootstrap import vltest_bootstrap
test.scenarios('linter') test.scenarios('simulator')
test.lint(fails=True, expect_filename=test.golden_filename) test.compile()
test.execute()
test.passes() test.passes()