Fix unpacked-in-class pattern assignment

This commit is contained in:
Wilson Snyder 2021-03-13 13:39:29 -05:00
parent e3788e871e
commit 9dcda6947d
3 changed files with 7 additions and 1 deletions

View File

@ -67,6 +67,8 @@ class SliceVisitor final : public AstNVisitor {
nodep->v3error(
nodep->prettyTypeName()
<< " is not an unpacked array, but is in an unpacked array context");
} else {
V3Error::incErrors(); // Otherwise might infinite loop
}
m_assignError = true;
return nodep->cloneTree(false); // Likely will cause downstream errors
@ -107,7 +109,7 @@ class SliceVisitor final : public AstNVisitor {
: offset));
newp = new AstArraySel(nodep->fileline(), snodep->fromp()->cloneTree(false), leOffset);
} else if (VN_IS(nodep, ArraySel) || VN_IS(nodep, NodeVarRef) || VN_IS(nodep, NodeSel)
|| VN_IS(nodep, CMethodHard)) {
|| VN_IS(nodep, CMethodHard) || VN_IS(nodep, MemberSel)) {
UINFO(9, " cloneSel(" << elements << "," << offset << ") " << nodep << endl);
int leOffset = !arrayp->rangep()->littleEndian()
? arrayp->rangep()->elementsConst() - 1 - offset

View File

@ -1,2 +1,3 @@
''{b:'h1, i:'h2a, carray4:'{'h11, 'h22, 'h33, 'h44} }'
''{b:'h1, i:'h2a, carray4:'{'h911, 'h922, 'h933, 'h944} }'
*-* All Finished *-*

View File

@ -30,6 +30,9 @@ module t (/*AUTOARG*/);
c.carray4[3] = 16'h44;
$display("'%p'", c);
c.carray4 = '{16'h911, 16'h922, 16'h933, 16'h944};
$display("'%p'", c);
$write("*-* All Finished *-*\n");
$finish;
end