Support class extends of package::class.

This commit is contained in:
Wilson Snyder 2023-03-18 17:26:36 -04:00
parent 895ab8789b
commit 2b21697b86
6 changed files with 33 additions and 26 deletions

View File

@ -17,6 +17,7 @@ Verilator 5.009 devel
* Add --public-params flag (#3990). [Andrew Nolte] * Add --public-params flag (#3990). [Andrew Nolte]
* Support complicated IEEE 'for' assignments. * Support complicated IEEE 'for' assignments.
* Support $fopen as an expression. * Support $fopen as an expression.
* Support class extends of package::class.
* Change ZERODLY to a warning. * Change ZERODLY to a warning.
* Fix UNDRIVEN warning seg fault (#3989). [Felix Neumärker] * Fix UNDRIVEN warning seg fault (#3989). [Felix Neumärker]
* Fix symbol entries when inheriting classes (#3995) (#3996). [Krzysztof Boroński] * Fix symbol entries when inheriting classes (#3995) (#3996). [Krzysztof Boroński]

View File

@ -3272,17 +3272,26 @@ private:
" (IEEE 1800-2017 8.13)"); " (IEEE 1800-2017 8.13)");
} }
if (cextp->childDTypep() || cextp->dtypep()) continue; // Already converted if (cextp->childDTypep() || cextp->dtypep()) continue; // Already converted
if (VN_IS(cextp->classOrPkgsp(), Dot)) { AstNode* cprp = cextp->classOrPkgsp();
itemp->v3warn(E_UNSUPPORTED, "Unsupported: Hierarchical class references"); VSymEnt* lookSymp = m_curSymp;
continue; if (AstDot* const dotp = VN_CAST(cextp->classOrPkgsp(), Dot)) {
dotp->user3(true);
if (AstClassOrPackageRef* lookNodep
= VN_CAST(dotp->lhsp(), ClassOrPackageRef)) {
iterate(lookNodep);
cprp = dotp->rhsp();
lookSymp = m_statep->getNodeSym(lookNodep->classOrPackagep());
} else {
dotp->lhsp()->v3error("Attempting to extend" // LCOV_EXCL_LINE
" using non-class under dot");
}
} }
AstClassOrPackageRef* const cpackagerefp AstClassOrPackageRef* const cpackagerefp = VN_CAST(cprp, ClassOrPackageRef);
= VN_CAST(cextp->classOrPkgsp(), ClassOrPackageRef);
if (VL_UNCOVERABLE(!cpackagerefp)) { if (VL_UNCOVERABLE(!cpackagerefp)) {
// Linking the extend gives an error before this is hit // Linking the extend gives an error before this is hit
cextp->v3error("Attempting to extend using non-class"); // LCOV_EXCL_LINE cextp->v3error("Attempting to extend using non-class"); // LCOV_EXCL_LINE
} else { } else {
VSymEnt* const foundp = m_curSymp->findIdFallback(cpackagerefp->name()); VSymEnt* const foundp = lookSymp->findIdFallback(cpackagerefp->name());
if (foundp) { if (foundp) {
AstClassRefDType* classRefDtypep = nullptr; AstClassRefDType* classRefDtypep = nullptr;
AstClass* classp = VN_CAST(foundp->nodep(), Class); AstClass* classp = VN_CAST(foundp->nodep(), Class);
@ -3353,8 +3362,9 @@ private:
if (!cextp->isImplements()) { if (!cextp->isImplements()) {
m_curSymp->importFromClass(m_statep->symsp(), srcp); m_curSymp->importFromClass(m_statep->symsp(), srcp);
} }
VL_DO_DANGLING(cpackagerefp->unlinkFrBack()->deleteTree(), VL_DO_DANGLING(
cpackagerefp); cextp->classOrPkgsp()->unlinkFrBack()->deleteTree(),
cpackagerefp);
} }
} }
} else { } else {

View File

@ -1,5 +0,0 @@
%Error-UNSUPPORTED: t/t_class_extends2.v:18:19: Unsupported: Hierarchical class references
18 | class Ext extends Pkg::Base0;
| ^~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error: Exiting due to

View File

@ -8,11 +8,14 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(linter => 1); scenarios(simulator => 1);
lint( compile(
fails => $Self->{vlt}, make_flags => 'VM_PARALLEL_BUILDS=1', # bug2775
expect_filename => $Self->{golden_filename}, );
execute(
check_finished => 1,
); );
ok(1); ok(1);

View File

@ -1,5 +0,0 @@
%Error-UNSUPPORTED: t/t_class_extends_colon.v:20:21: Unsupported: Hierarchical class references
20 | class Cls12 extends Pkg::Icls1;
| ^~~
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
%Error: Exiting due to

View File

@ -8,11 +8,14 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
scenarios(linter => 1); scenarios(simulator => 1);
lint( compile(
fails => $Self->{vlt}, make_flags => 'VM_PARALLEL_BUILDS=1', # bug2775
expect_filename => $Self->{golden_filename}, );
execute(
check_finished => 1,
); );
ok(1); ok(1);