Internals: Remove V3LinkParse's need of class links. No functional change intended.
This commit is contained in:
parent
92dd8ee8f5
commit
80cba789f4
|
|
@ -3066,6 +3066,9 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
||||||
VL_RESTORER(m_ds);
|
VL_RESTORER(m_ds);
|
||||||
VL_RESTORER(m_pinSymp);
|
VL_RESTORER(m_pinSymp);
|
||||||
|
|
||||||
|
if (nodep->name() == "std" && !nodep->classOrPackagep()) {
|
||||||
|
nodep->classOrPackagep(v3Global.rootp()->stdPackagep());
|
||||||
|
}
|
||||||
// ClassRef's have pins, so track
|
// ClassRef's have pins, so track
|
||||||
if (nodep->classOrPackagep()) {
|
if (nodep->classOrPackagep()) {
|
||||||
m_pinSymp = m_statep->getNodeSym(nodep->classOrPackagep());
|
m_pinSymp = m_statep->getNodeSym(nodep->classOrPackagep());
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ class LinkParseVisitor final : public VNVisitor {
|
||||||
using ImplTypedefMap = std::map<const std::pair<void*, std::string>, AstTypedef*>;
|
using ImplTypedefMap = std::map<const std::pair<void*, std::string>, AstTypedef*>;
|
||||||
|
|
||||||
// STATE
|
// STATE
|
||||||
AstPackage* const m_stdPackagep; // SystemVerilog std package
|
|
||||||
AstVar* m_varp = nullptr; // Variable we're under
|
AstVar* m_varp = nullptr; // Variable we're under
|
||||||
ImplTypedefMap m_implTypedef; // Created typedefs for each <container,name>
|
ImplTypedefMap m_implTypedef; // Created typedefs for each <container,name>
|
||||||
std::unordered_set<FileLine*> m_filelines; // Filelines that have been seen
|
std::unordered_set<FileLine*> m_filelines; // Filelines that have been seen
|
||||||
|
|
@ -192,9 +191,7 @@ class LinkParseVisitor final : public VNVisitor {
|
||||||
if (!nodep->lifetime().isNone()) {
|
if (!nodep->lifetime().isNone()) {
|
||||||
m_lifetime = nodep->lifetime();
|
m_lifetime = nodep->lifetime();
|
||||||
} else {
|
} else {
|
||||||
const AstClassOrPackageRef* const classPkgRefp
|
if (nodep->classMethod()) {
|
||||||
= VN_AS(nodep->classOrPackagep(), ClassOrPackageRef);
|
|
||||||
if (classPkgRefp && VN_IS(classPkgRefp->classOrPackageNodep(), Class)) {
|
|
||||||
// Class methods are automatic by default
|
// Class methods are automatic by default
|
||||||
m_lifetime = VLifetime::AUTOMATIC;
|
m_lifetime = VLifetime::AUTOMATIC;
|
||||||
} else if (nodep->dpiImport() || VN_IS(nodep, Property)) {
|
} else if (nodep->dpiImport() || VN_IS(nodep, Property)) {
|
||||||
|
|
@ -841,10 +838,8 @@ class LinkParseVisitor final : public VNVisitor {
|
||||||
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void visit(AstClassOrPackageRef* nodep) override {
|
void visit(AstClassOrPackageRef* nodep) override { //
|
||||||
if (nodep->name() == "std" && !nodep->classOrPackagep()) {
|
iterateChildren(nodep);
|
||||||
nodep->classOrPackagep(m_stdPackagep);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void visit(AstClocking* nodep) override {
|
void visit(AstClocking* nodep) override {
|
||||||
cleanFileline(nodep);
|
cleanFileline(nodep);
|
||||||
|
|
@ -917,10 +912,7 @@ class LinkParseVisitor final : public VNVisitor {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
explicit LinkParseVisitor(AstNetlist* rootp)
|
explicit LinkParseVisitor(AstNetlist* rootp) { iterate(rootp); }
|
||||||
: m_stdPackagep{rootp->stdPackagep()} {
|
|
||||||
iterate(rootp);
|
|
||||||
}
|
|
||||||
~LinkParseVisitor() override {
|
~LinkParseVisitor() override {
|
||||||
V3Stats::addStatSum(V3Stats::STAT_SOURCE_MODULES, m_statModules);
|
V3Stats::addStatSum(V3Stats::STAT_SOURCE_MODULES, m_statModules);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4579,6 +4579,7 @@ taskId<nodeFTaskp>:
|
||||||
| packageClassScope id
|
| packageClassScope id
|
||||||
{ $$ = new AstTask{$<fl>$, *$2, nullptr};
|
{ $$ = new AstTask{$<fl>$, *$2, nullptr};
|
||||||
$$->classOrPackagep($1);
|
$$->classOrPackagep($1);
|
||||||
|
$$->classMethod(true);
|
||||||
SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
|
SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -4620,6 +4621,7 @@ funcIdNew<nodeFTaskp>: // IEEE: from class_constructor_declaration
|
||||||
{ $$ = new AstFunc{$<fl>2, "new", nullptr, nullptr};
|
{ $$ = new AstFunc{$<fl>2, "new", nullptr, nullptr};
|
||||||
$$->classOrPackagep($1);
|
$$->classOrPackagep($1);
|
||||||
$$->isConstructor(true);
|
$$->isConstructor(true);
|
||||||
|
$$->classMethod(true);
|
||||||
SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
|
SYMP->pushNewUnderNodeOrCurrent($$, $<scp>1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -4640,6 +4642,7 @@ fIdScoped<funcp>: // IEEE: part of function_body_declaration/task_
|
||||||
{ $<fl>$ = $<fl>1;
|
{ $<fl>$ = $<fl>1;
|
||||||
$<scp>$ = $<scp>1;
|
$<scp>$ = $<scp>1;
|
||||||
$$ = new AstFunc{$<fl>$, *$2, nullptr, nullptr};
|
$$ = new AstFunc{$<fl>$, *$2, nullptr, nullptr};
|
||||||
|
$$->classMethod(true);
|
||||||
$$->classOrPackagep($1); }
|
$$->classOrPackagep($1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
%Error: Internal Error: t/t_class_ref_bad.v:15:11: ../V3LinkDot.cpp:#: Bad package link
|
||||||
|
15 | s = ClsRigh::m_s;
|
||||||
|
| ^~~~~~~
|
||||||
|
... See the manual at https://verilator.org/verilator_doc.html for more assistance.
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2024 by Wilson Snyder. This program is free software; you
|
||||||
|
# can redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
|
import vltest_bootstrap
|
||||||
|
|
||||||
|
test.scenarios('linter')
|
||||||
|
|
||||||
|
test.lint(fails=True, expect_filename=test.golden_filename)
|
||||||
|
|
||||||
|
test.passes()
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||||
|
// any use, without warranty, 2024 by Wilson Snyder.
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
class ClsRight;
|
||||||
|
string m_s;
|
||||||
|
endclass
|
||||||
|
|
||||||
|
module t (/*AUTOARG*/);
|
||||||
|
string s;
|
||||||
|
initial begin
|
||||||
|
// verilator lint_off PKGNODECL
|
||||||
|
s = ClsRigh::m_s; // Bad typo
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
Loading…
Reference in New Issue