Fix pattern assignment to conditionals, bug769.

This commit is contained in:
Wilson Snyder 2014-06-06 21:52:16 -04:00
parent a428e7f618
commit 5da5678e64
3 changed files with 88 additions and 74 deletions

View File

@ -15,7 +15,9 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix seg-fault with variable of parameterized interface, bug692. [Jie Xu] **** Fix seg-fault with variable of parameterized interface, bug692. [Jie Xu]
**** Fix pattern assignment to arrayed basic type, bug769. [Jie Xu] **** Fix pattern assignment to basic types, bug767. [Jie Xu]
**** Fix pattern assignment to conditionals, bug769. [Jie Xu]
**** Fix shift corner-cases, bug765, bug766, bug768, bug772, bug776. [Clifford Wolf] **** Fix shift corner-cases, bug765, bug766, bug768, bug772, bug776. [Clifford Wolf]

View File

@ -314,8 +314,9 @@ private:
// Just once, do the conditional, expect one bit out. // Just once, do the conditional, expect one bit out.
iterateCheckBool(nodep,"Conditional Test",nodep->condp(),BOTH); iterateCheckBool(nodep,"Conditional Test",nodep->condp(),BOTH);
// Determine sub expression widths only relying on what's in the subops // Determine sub expression widths only relying on what's in the subops
nodep->expr1p()->iterateAndNext(*this,WidthVP(CONTEXT,PRELIM).p()); // CONTEXT determined, but need data type for pattern assignments
nodep->expr2p()->iterateAndNext(*this,WidthVP(CONTEXT,PRELIM).p()); nodep->expr1p()->iterateAndNext(*this,WidthVP(vup->c()->dtypeNullp(),PRELIM).p());
nodep->expr2p()->iterateAndNext(*this,WidthVP(vup->c()->dtypeNullp(),PRELIM).p());
// Calculate width of this expression. // Calculate width of this expression.
// First call (prelim()) vup->c()->width() is probably zero, so we'll return // First call (prelim()) vup->c()->width() is probably zero, so we'll return
// the size of this subexpression only. // the size of this subexpression only.
@ -1369,11 +1370,14 @@ private:
patp = newpatp; patp = newpatp;
} }
else { else {
if (!classp->castUnionDType()) {
patp->v3error("Assignment pattern missed initializing elements: "<<memp->prettyTypeName()); patp->v3error("Assignment pattern missed initializing elements: "<<memp->prettyTypeName());
} }
}
} else { } else {
patp = it->second; patp = it->second;
} }
if (patp) {
// Determine initial values // Determine initial values
vdtypep = memp; vdtypep = memp;
patp->dtypep(memp); patp->dtypep(memp);
@ -1395,6 +1399,7 @@ private:
concatp->lhsp()->width()+concatp->rhsp()->width(), concatp->lhsp()->width()+concatp->rhsp()->width(),
nodep->dtypep()->numeric()); nodep->dtypep()->numeric());
} }
}
if (newpatp) { pushDeletep(newpatp); newpatp=NULL; } if (newpatp) { pushDeletep(newpatp); newpatp=NULL; }
} }
if (newp) nodep->replaceWith(newp); if (newp) nodep->replaceWith(newp);
@ -1424,6 +1429,7 @@ private:
patmap.erase(it); patmap.erase(it);
} }
if (patp) {
// Determine initial values // Determine initial values
vdtypep = arrayp->subDTypep(); vdtypep = arrayp->subDTypep();
// Don't want the RHS an array // Don't want the RHS an array
@ -1457,6 +1463,7 @@ private:
nodep->dtypep()->numeric()); nodep->dtypep()->numeric());
} }
} }
}
if (newpatp) { pushDeletep(newpatp); newpatp=NULL; } if (newpatp) { pushDeletep(newpatp); newpatp=NULL; }
} }
if (!patmap.empty()) nodep->v3error("Assignment pattern with too many elements"); if (!patmap.empty()) nodep->v3error("Assignment pattern with too many elements");
@ -1488,6 +1495,7 @@ private:
patp = it->second; patp = it->second;
patmap.erase(it); patmap.erase(it);
} }
if (patp) {
// Determine initial values // Determine initial values
vdtypep = nodep->findLogicBoolDType(); vdtypep = nodep->findLogicBoolDType();
// Don't want the RHS an array // Don't want the RHS an array
@ -1513,6 +1521,7 @@ private:
nodep->dtypep()->numeric()); nodep->dtypep()->numeric());
} }
} }
}
if (newpatp) { pushDeletep(newpatp); newpatp=NULL; } if (newpatp) { pushDeletep(newpatp); newpatp=NULL; }
} }
if (!patmap.empty()) nodep->v3error("Assignment pattern with too many elements"); if (!patmap.empty()) nodep->v3error("Assignment pattern with too many elements");

View File

@ -67,6 +67,9 @@ module t;
if (tsu.pack2.four.quad1.b2 != 1'b0) $stop; if (tsu.pack2.four.quad1.b2 != 1'b0) $stop;
if (tsu.pack2.four.quad1.b3 != 1'b1) $stop; if (tsu.pack2.four.quad1.b3 != 1'b1) $stop;
// //
tsu = 1'b0 ? '0 : '{pvec: 6'b101011};
if (tsu!=6'b101011) $stop;
//
arr[0] = 6'b101010; arr[0] = 6'b101010;
arr[1] = 6'b010101; arr[1] = 6'b010101;
if (arr[0].four !== 4'b0101) $stop; if (arr[0].four !== 4'b0101) $stop;