Improve too-small cast warning to show size

This commit is contained in:
Wilson Snyder 2026-04-12 18:12:41 -04:00
parent be7d26c5be
commit fac07970e6
2 changed files with 2 additions and 2 deletions

View File

@ -2631,7 +2631,7 @@ class WidthVisitor final : public VNVisitor {
if (m_vup->prelim()) {
int width = nodep->rhsp()->toSInt();
if (width < 1) {
nodep->v3error("Size-changing cast to zero or negative size");
nodep->v3error("Size-changing cast to zero or negative size: " << width);
width = 1;
}
userIterateAndNext(nodep->lhsp(), WidthVP{SELF, PRELIM}.p());

View File

@ -1,4 +1,4 @@
%Error: t/t_cast_size_bad.v:14:13: Size-changing cast to zero or negative size
%Error: t/t_cast_size_bad.v:14:13: Size-changing cast to zero or negative size: -1
: ... note: In instance 't'
14 | b = (-1)'(a);
| ^