Better message for display-like format warnings, bug500.

This commit is contained in:
Wilson Snyder 2012-05-02 21:04:50 -04:00
parent 6aab0f627c
commit b9101c3d6a
4 changed files with 15 additions and 15 deletions

View File

@ -1192,11 +1192,11 @@ void EmitCStmts::displayArg(AstNode* dispp, AstNode** elistp, bool isScan,
AstNode* argp = *elistp; AstNode* argp = *elistp;
if (!argp) { if (!argp) {
// expectDisplay() checks this first, so internal error if found here // expectDisplay() checks this first, so internal error if found here
dispp->v3error("Internal: Missing arguments for $display format"); dispp->v3error("Internal: Missing arguments for $display-like format");
return; return;
} }
if (argp->widthMin() > VL_VALUE_STRING_MAX_WIDTH) { if (argp->widthMin() > VL_VALUE_STRING_MAX_WIDTH) {
dispp->v3error("Exceeded limit of "+cvtToStr(VL_VALUE_STRING_MAX_WIDTH)+" bits for any display arguments"); dispp->v3error("Exceeded limit of "+cvtToStr(VL_VALUE_STRING_MAX_WIDTH)+" bits for any $display-like arguments");
} }
if (argp && argp->isWide() if (argp && argp->isWide()
&& (fmtLetter=='d'||fmtLetter=='u')) { && (fmtLetter=='d'||fmtLetter=='u')) {
@ -1287,17 +1287,17 @@ void EmitCStmts::displayNode(AstNode* nodep, AstScopeName* scopenamep,
case 'z': case 'z':
case 'l': case 'l':
case 'v': case 'v':
nodep->v3error("Unsupported: $display format code: %"<<pos[0]); nodep->v3error("Unsupported: $display-like format code: %"<<pos[0]);
break; break;
default: default:
nodep->v3error("Unknown $display format code: %"<<pos[0]); nodep->v3error("Unknown $display-like format code: %"<<pos[0]);
break; break;
} }
} }
} }
if (elistp != NULL) { if (elistp != NULL) {
// expectFormat also checks this, and should have found it first, so internal // expectFormat also checks this, and should have found it first, so internal
elistp->v3error("Internal: Extra arguments for $display format"); elistp->v3error("Internal: Extra arguments for $display-like format");
} }
displayEmit(nodep, isScan); displayEmit(nodep, isScan);
} }

View File

@ -260,10 +260,10 @@ private:
break; break;
default: // Most operators, just move to next argument default: // Most operators, just move to next argument
if (!V3Number::displayedFmtLegal(ch)) { if (!V3Number::displayedFmtLegal(ch)) {
nodep->v3error("Unknown $display format code: %"<<ch); nodep->v3error("Unknown $display-like format code: %"<<ch);
} else { } else {
if (!argp) { if (!argp) {
nodep->v3error("Missing arguments for $display format"); nodep->v3error("Missing arguments for $display-like format");
} else { } else {
argp = argp->nextp(); argp = argp->nextp();
} }
@ -273,7 +273,7 @@ private:
} }
} }
if (argp) { if (argp) {
argp->v3error("Extra arguments for $display format"); argp->v3error("Extra arguments for $display-like format");
} }
} }

View File

@ -401,7 +401,7 @@ bool V3Number::displayedFmtLegal(char format) {
string V3Number::displayed(const string& vformat) const { string V3Number::displayed(const string& vformat) const {
string::const_iterator pos = vformat.begin(); string::const_iterator pos = vformat.begin();
UASSERT(pos != vformat.end() && pos[0]=='%', "display with non format argument "<<*this); UASSERT(pos != vformat.end() && pos[0]=='%', "$display-like function with non format argument "<<*this);
++pos; ++pos;
string fmtsize; string fmtsize;
for (; pos != vformat.end() && (isdigit(pos[0]) || pos[0]=='.'); ++pos) { for (; pos != vformat.end() && (isdigit(pos[0]) || pos[0]=='.'); ++pos) {
@ -444,7 +444,7 @@ string V3Number::displayed(const string& vformat) const {
return str; return str;
} }
case 'c': { case 'c': {
if (this->width()>8) m_fileline->v3error("$display of char format of > 8 bit value"); if (this->width()>8) m_fileline->v3error("$display-like format of char of > 8 bit value");
int v = bitsValue(0, 8); int v = bitsValue(0, 8);
str += (char)(v); str += (char)(v);
return str; return str;
@ -477,7 +477,7 @@ string V3Number::displayed(const string& vformat) const {
fmtsize = cvtToStr(int(dchars)); fmtsize = cvtToStr(int(dchars));
} }
if (width() > 64) { if (width() > 64) {
m_fileline->v3error("Unsupported: $display of dec format of > 64 bit results (use hex format instead)"); m_fileline->v3error("Unsupported: $display-like format of decimal of > 64 bit results (use hex format instead)");
return "ERR"; return "ERR";
} }
if (issigned) { if (issigned) {
@ -501,7 +501,7 @@ string V3Number::displayed(const string& vformat) const {
return tmp; return tmp;
} }
default: default:
m_fileline->v3fatalSrc("Unknown $display format code for number: %"<<pos[0]); m_fileline->v3fatalSrc("Unknown $display-like format code for number: %"<<pos[0]);
return "ERR"; return "ERR";
} }
} }

View File

@ -11,9 +11,9 @@ compile (
v_flags2 => ["--lint-only"], v_flags2 => ["--lint-only"],
fails=>1, fails=>1,
expect=> expect=>
'%Error: t/t_display_bad.v:\d+: Missing arguments for \$display format '%Error: t/t_display_bad.v:\d+: Missing arguments for \$display-like format
%Error: t/t_display_bad.v:\d+: Extra arguments for \$display format %Error: t/t_display_bad.v:\d+: Extra arguments for \$display-like format
%Error: t/t_display_bad.v:\d+: Unknown \$display format code: %q %Error: t/t_display_bad.v:\d+: Unknown \$display-like format code: %q
%Error: Exiting due to.*', %Error: Exiting due to.*',
); );