Fix $sformat with non-constant string first argument

This commit is contained in:
Wilson Snyder 2020-06-09 19:40:49 -04:00
parent 6de78d58fa
commit 3c8953fec2
3 changed files with 6 additions and 10 deletions

View File

@ -3570,10 +3570,11 @@ public:
addNOp1p(exprsp);
addNOp2p(NULL);
}
AstSFormatF(FileLine* fl, NoFormat, AstNode* exprsp, char missingArgChar = 'd')
AstSFormatF(FileLine* fl, NoFormat, AstNode* exprsp, char missingArgChar = 'd',
bool hidden = true)
: ASTGEN_SUPER(fl)
, m_text("")
, m_hidden(true)
, m_hidden(hidden)
, m_hasFormat(false)
, m_missingArgChar(missingArgChar) {
dtypeSetString();

View File

@ -3642,7 +3642,7 @@ system_f_call_or_t<nodep>: // IEEE: part of system_tf_call (can be task or func)
| yD_RIGHT '(' exprOrDataType ',' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_RIGHT,$3,$5); }
| yD_RTOI '(' expr ')' { $$ = new AstRToIS($1,$3); }
| yD_SAMPLED '(' expr ')' { $$ = new AstSampled($1, $3); }
| yD_SFORMATF '(' str commaEListE ')' { $$ = new AstSFormatF($1,*$3,false,$4); }
| yD_SFORMATF '(' exprDispList ')' { $$ = new AstSFormatF($1, AstSFormatF::NoFormat(), $3, 'd', false); }
| yD_SHORTREALTOBITS '(' expr ')' { $$ = new AstRealToBits($1,$3); UNSUPREAL($1); }
| yD_SIGNED '(' expr ')' { $$ = new AstSigned($1,$3); }
| yD_SIN '(' expr ')' { $$ = new AstSinD($1,$3); }
@ -4313,11 +4313,6 @@ exprDispList<nodep>: // exprList for within $display
{ $$ = $1; $1->addNext(new AstConst($<fl>2, AstConst::VerilogStringLiteral(), " ")); }
;
commaEListE<nodep>:
/* empty */ { $$ = NULL; }
| ',' exprList { $$ = $2; }
;
vrdList<nodep>:
idClassSel { $$ = $1; }
| vrdList ',' idClassSel { $$ = $1;$1->addNext($3); }

View File

@ -62,11 +62,11 @@ module t;
if (str2 !== "lib=t") $stop;
str3 = $sformatf("u=%u", {"a","b","c","d"}); // Value selected so is printable
`ifdef TEST_VERBOSE $display("chku %s %s",str3,str3); `endif
`ifdef TEST_VERBOSE $display("chku %s", str3); `endif
if (str3 !== "u=dcba") $stop;
str3 = $sformatf("v=%v", {"a","b","c","d"}); // Value selected so is printable
`ifdef TEST_VERBOSE $display("chkv %s %s",str3,str3); `endif
`ifdef TEST_VERBOSE $display("chkv %s", str3); `endif
$sformat(ochar,"%s","c");
if (ochar != "c") $stop;