Fix range access to fields under classes that depend on parameter resolution (#4681)

Signed-off-by: Krzysztof Boronski <[email protected]>
This commit is contained in:
Krzysztof Boroński
2023-11-15 14:24:41 +01:00
committed by GitHub
parent 2dba76a7c2
commit cc982ec7fe
5 changed files with 82 additions and 15 deletions
+1 -1
View File
@@ -931,7 +931,7 @@ AstNode* AstArraySel::baseFromp(AstNode* nodep, bool overMembers) {
nodep = VN_AS(nodep, MemberSel)->fromp();
continue;
}
// AstNodeSelPre stashes the associated variable under an ATTROF
// AstNodePreSel stashes the associated variable under an ATTROF
// of VAttrType::VAR_BASE so it isn't constified
else if (VN_IS(nodep, AttrOf)) {
nodep = VN_AS(nodep, AttrOf)->fromp();
+15 -1
View File
@@ -3343,7 +3343,19 @@ class LinkDotResolveVisitor final : public VNVisitor {
m_ds.init(m_curSymp);
iterateAndNextNull(nodep->rhsp());
iterateAndNextNull(nodep->thsp());
iterateAndNextNull(nodep->attrp());
}
if (nodep->attrp()) {
AstNode* const attrp = nodep->attrp()->unlinkFrBack();
VL_DO_DANGLING(attrp->deleteTree(), attrp);
}
AstNode* const basefromp = AstArraySel::baseFromp(nodep, false);
if (VN_IS(basefromp, Replicate)) {
// From {...}[...] syntax in IEEE 2017
if (basefromp) UINFO(1, " Related node: " << basefromp << endl);
} else {
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE,
basefromp->cloneTree(false)});
}
}
void visit(AstMemberSel* nodep) override {
@@ -3742,6 +3754,8 @@ class LinkDotResolveVisitor final : public VNVisitor {
iterateChildren(nodep);
}
void visit(AstAttrOf* nodep) override { iterateChildren(nodep); }
void visit(AstNode* nodep) override {
checkNoDot(nodep);
iterateChildren(nodep);
-13
View File
@@ -181,19 +181,6 @@ class LinkResolveVisitor final : public VNVisitor {
nodep->scopeNamep(new AstScopeName{nodep->fileline(), false});
}
}
void visit(AstNodePreSel* nodep) override {
if (!nodep->attrp()) {
iterateChildren(nodep);
AstNode* const basefromp = AstArraySel::baseFromp(nodep, false);
if (VN_IS(basefromp, Replicate)) {
// From {...}[...] syntax in IEEE 2017
if (basefromp) UINFO(1, " Related node: " << basefromp << endl);
} else {
nodep->attrp(new AstAttrOf{nodep->fileline(), VAttrType::VAR_BASE,
basefromp->cloneTree(false)});
}
}
}
void visit(AstCaseItem* nodep) override {
// Move default caseItems to the bottom of the list