mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 12:17:35 +00:00
Add elaboration dot-error message context, plus debug improvements
This commit is contained in:
parent
8638e46cb7
commit
d06f986b51
@ -2175,14 +2175,17 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
}
|
}
|
||||||
string ascii() const {
|
string ascii() const {
|
||||||
static const char* const names[]
|
static const char* const names[]
|
||||||
= {"NONE", "PACKAGE", "FIRST", "SCOPE", "FINAL", "MEMBER"};
|
= {"DP_NONE", "DP_PACKAGE", "DP_FIRST", "DP_SCOPE", "DP_FINAL", "DP_MEMBER"};
|
||||||
std::ostringstream sstr;
|
std::ostringstream sstr;
|
||||||
sstr << "ds=" << names[m_dotPos];
|
sstr << "ds=" << names[m_dotPos];
|
||||||
sstr << " dse" << cvtToHex(m_dotSymp);
|
sstr << " dse" << cvtToHex(m_dotSymp);
|
||||||
sstr << " sup=" << m_super;
|
sstr << "(" << m_dotSymp->nodep()->typeName() << ")";
|
||||||
|
|
||||||
|
if (m_dotErr) sstr << " [dotErr]";
|
||||||
|
if (m_super) sstr << " [super]";
|
||||||
|
if (m_unresolvedCell) sstr << " [unrCell]";
|
||||||
|
if (m_unresolvedClass) sstr << " [unrClass]";
|
||||||
sstr << " txt=" << m_dotText;
|
sstr << " txt=" << m_dotText;
|
||||||
sstr << " unrCell=" << m_unresolvedCell;
|
|
||||||
sstr << " unrClass=" << m_unresolvedClass;
|
|
||||||
return sstr.str();
|
return sstr.str();
|
||||||
}
|
}
|
||||||
} m_ds; // State to preserve across recursions
|
} m_ds; // State to preserve across recursions
|
||||||
@ -2265,9 +2268,12 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
void checkNoDot(AstNode* nodep) {
|
void checkNoDot(AstNode* nodep) {
|
||||||
if (VL_UNLIKELY(m_ds.m_dotPos != DP_NONE)) {
|
if (VL_UNLIKELY(m_ds.m_dotPos != DP_NONE)) {
|
||||||
// UINFO(9, indent() << "ds=" << m_ds.ascii() << endl);
|
// UINFO(9, indent() << "ds=" << m_ds.ascii() << endl);
|
||||||
nodep->v3error("Syntax error: Not expecting " << nodep->type() << " under a "
|
nodep->v3error("Syntax error: Not expecting "
|
||||||
<< nodep->backp()->type()
|
<< nodep->type() << " under a " << nodep->backp()->type()
|
||||||
<< " in dotted expression");
|
<< " in dotted expression\n"
|
||||||
|
<< nodep->warnContextPrimary() << m_ds.m_dotp->warnOther()
|
||||||
|
<< "... Resolving this reference\n"
|
||||||
|
<< m_ds.m_dotp->warnContextSecondary());
|
||||||
m_ds.m_dotErr = true;
|
m_ds.m_dotErr = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2440,6 +2446,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
void visit(AstCell* nodep) override {
|
void visit(AstCell* nodep) override {
|
||||||
// Cell: Recurse inside or cleanup not founds
|
// Cell: Recurse inside or cleanup not founds
|
||||||
LINKDOT_VISIT_START();
|
LINKDOT_VISIT_START();
|
||||||
|
UINFO(5, indent() << "visit " << nodep << endl);
|
||||||
checkNoDot(nodep);
|
checkNoDot(nodep);
|
||||||
VL_RESTORER(m_usedPins);
|
VL_RESTORER(m_usedPins);
|
||||||
m_usedPins.clear();
|
m_usedPins.clear();
|
||||||
@ -2459,7 +2466,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
// instantiator's symbols
|
// instantiator's symbols
|
||||||
else {
|
else {
|
||||||
m_pinSymp = m_statep->getNodeSym(nodep->modp());
|
m_pinSymp = m_statep->getNodeSym(nodep->modp());
|
||||||
UINFO(4, indent() << "(Backto) Link Cell: " << nodep << endl);
|
UINFO(4, indent() << "(Backto) visit " << nodep << endl);
|
||||||
// if (debug()) nodep->dumpTree("- linkcell: ");
|
// if (debug()) nodep->dumpTree("- linkcell: ");
|
||||||
// if (debug()) nodep->modp()->dumpTree("- linkcemd: ");
|
// if (debug()) nodep->modp()->dumpTree("- linkcemd: ");
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
@ -2471,6 +2478,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
void visit(AstClassRefDType* nodep) override {
|
void visit(AstClassRefDType* nodep) override {
|
||||||
// Cell: Recurse inside or cleanup not founds
|
// Cell: Recurse inside or cleanup not founds
|
||||||
LINKDOT_VISIT_START();
|
LINKDOT_VISIT_START();
|
||||||
|
UINFO(5, indent() << "visit " << nodep << endl);
|
||||||
checkNoDot(nodep);
|
checkNoDot(nodep);
|
||||||
VL_RESTORER(m_usedPins);
|
VL_RESTORER(m_usedPins);
|
||||||
m_usedPins.clear();
|
m_usedPins.clear();
|
||||||
@ -2481,7 +2489,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
{
|
{
|
||||||
// ClassRef's have pins, so track
|
// ClassRef's have pins, so track
|
||||||
m_pinSymp = m_statep->getNodeSym(nodep->classp());
|
m_pinSymp = m_statep->getNodeSym(nodep->classp());
|
||||||
UINFO(4, indent() << "(Backto) Link ClassRefDType: " << nodep << endl);
|
UINFO(4, indent() << "(Backto) visit " << nodep << endl);
|
||||||
// if (debug()) nodep->dumpTree("- linkcell: ");
|
// if (debug()) nodep->dumpTree("- linkcell: ");
|
||||||
// if (debug()) nodep->modp()->dumpTree("- linkcemd: ");
|
// if (debug()) nodep->modp()->dumpTree("- linkcemd: ");
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
@ -2692,7 +2700,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
|
|
||||||
if (start) {
|
if (start) {
|
||||||
m_ds.init(m_curSymp);
|
m_ds.init(m_curSymp);
|
||||||
// Note m_ds.m_dot remains nullptr; this is a reference not under a dot
|
// Note m_ds.m_dotp remains nullptr; this is a reference not under a dot
|
||||||
}
|
}
|
||||||
if (nodep->name() == "super") {
|
if (nodep->name() == "super") {
|
||||||
nodep->v3warn(E_UNSUPPORTED, "Unsupported: super");
|
nodep->v3warn(E_UNSUPPORTED, "Unsupported: super");
|
||||||
@ -2720,7 +2728,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
// m_ds.dotp->lhsp() was checked to know if `index` is directly after lambda arg ref.
|
// m_ds.dotp->lhsp() was checked to know if `index` is directly after lambda arg ref.
|
||||||
// If not, treat it as normal member select
|
// If not, treat it as normal member select
|
||||||
iterateChildren(nodep);
|
iterateChildren(nodep);
|
||||||
const auto newp = new AstLambdaArgRef{
|
AstLambdaArgRef* const newp = new AstLambdaArgRef{
|
||||||
nodep->fileline(), m_ds.m_dotp->lhsp()->name() + "__DOT__index", true};
|
nodep->fileline(), m_ds.m_dotp->lhsp()->name() + "__DOT__index", true};
|
||||||
nodep->replaceWith(newp);
|
nodep->replaceWith(newp);
|
||||||
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
||||||
@ -3286,6 +3294,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
void visit(AstMethodCall* nodep) override {
|
void visit(AstMethodCall* nodep) override {
|
||||||
// Created here so should already be resolved.
|
// Created here so should already be resolved.
|
||||||
LINKDOT_VISIT_START();
|
LINKDOT_VISIT_START();
|
||||||
|
UINFO(5, indent() << "visit " << nodep << endl);
|
||||||
VL_RESTORER(m_ds);
|
VL_RESTORER(m_ds);
|
||||||
VL_RESTORER(m_fromSymp);
|
VL_RESTORER(m_fromSymp);
|
||||||
VL_RESTORER(m_randMethodCallp);
|
VL_RESTORER(m_randMethodCallp);
|
||||||
@ -3931,6 +3940,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
// Resolve its reference
|
// Resolve its reference
|
||||||
if (nodep->user3SetOnce()) return;
|
if (nodep->user3SetOnce()) return;
|
||||||
LINKDOT_VISIT_START();
|
LINKDOT_VISIT_START();
|
||||||
|
UINFO(5, indent() << "visit " << nodep << endl);
|
||||||
if (AstNode* const cpackagep = nodep->classOrPackageOpp()) {
|
if (AstNode* const cpackagep = nodep->classOrPackageOpp()) {
|
||||||
if (AstClassOrPackageRef* const cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) {
|
if (AstClassOrPackageRef* const cpackagerefp = VN_CAST(cpackagep, ClassOrPackageRef)) {
|
||||||
const AstClass* const clsp = VN_CAST(cpackagerefp->classOrPackageNodep(), Class);
|
const AstClass* const clsp = VN_CAST(cpackagerefp->classOrPackageNodep(), Class);
|
||||||
@ -4081,6 +4091,7 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void visit(AstIfaceRefDType* nodep) override {
|
void visit(AstIfaceRefDType* nodep) override {
|
||||||
|
if (nodep->user3SetOnce()) return;
|
||||||
LINKDOT_VISIT_START();
|
LINKDOT_VISIT_START();
|
||||||
if (nodep->paramsp()) {
|
if (nodep->paramsp()) {
|
||||||
// If there is no parameters, there is no need to visit this node.
|
// If there is no parameters, there is no need to visit this node.
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
%Error: t/t_concat_link_bad.v:13:20: Syntax error: Not expecting REPLICATE under a DOT in dotted expression
|
%Error: t/t_concat_link_bad.v:13:20: Syntax error: Not expecting REPLICATE under a DOT in dotted expression
|
||||||
13 | assign bar_s = {foo_s, foo_s}.f1;
|
13 | assign bar_s = {foo_s, foo_s}.f1;
|
||||||
| ^
|
| ^
|
||||||
|
t/t_concat_link_bad.v:13:34: ... Resolving this reference
|
||||||
|
13 | assign bar_s = {foo_s, foo_s}.f1;
|
||||||
|
| ^
|
||||||
%Error: t/t_concat_link_bad.v:13:26: Syntax error: Not expecting CONCAT under a REPLICATE in dotted expression
|
%Error: t/t_concat_link_bad.v:13:26: Syntax error: Not expecting CONCAT under a REPLICATE in dotted expression
|
||||||
13 | assign bar_s = {foo_s, foo_s}.f1;
|
13 | assign bar_s = {foo_s, foo_s}.f1;
|
||||||
| ^
|
| ^
|
||||||
|
t/t_concat_link_bad.v:13:34: ... Resolving this reference
|
||||||
|
13 | assign bar_s = {foo_s, foo_s}.f1;
|
||||||
|
| ^
|
||||||
%Error: t/t_concat_link_bad.v:13:20: Syntax error: Not expecting CONST under a REPLICATE in dotted expression
|
%Error: t/t_concat_link_bad.v:13:20: Syntax error: Not expecting CONST under a REPLICATE in dotted expression
|
||||||
13 | assign bar_s = {foo_s, foo_s}.f1;
|
13 | assign bar_s = {foo_s, foo_s}.f1;
|
||||||
| ^
|
| ^
|
||||||
|
t/t_concat_link_bad.v:13:34: ... Resolving this reference
|
||||||
|
13 | assign bar_s = {foo_s, foo_s}.f1;
|
||||||
|
| ^
|
||||||
%Warning-IMPLICIT: t/t_concat_link_bad.v:13:12: Signal definition not found, creating implicitly: 'bar_s'
|
%Warning-IMPLICIT: t/t_concat_link_bad.v:13:12: Signal definition not found, creating implicitly: 'bar_s'
|
||||||
13 | assign bar_s = {foo_s, foo_s}.f1;
|
13 | assign bar_s = {foo_s, foo_s}.f1;
|
||||||
| ^~~~~
|
| ^~~~~
|
||||||
|
Loading…
Reference in New Issue
Block a user