Fix display of %m in non-first argument (#7574).

Fixes #7574.
This commit is contained in:
Wilson Snyder 2026-05-11 08:18:34 -04:00
parent b0d58bbcef
commit 18e06b1e7d
5 changed files with 22 additions and 2 deletions

View File

@ -43,6 +43,7 @@ Verilator 5.049 devel
* Fix events in observed region (#7546). [Todd Strader]
* Fix regression rejecting boolean `!x` inside sequence expressions (#7549) (#7551). [Yilou Wang]
* Fix exponential expansion in V3Gate (#7550). [Geza Lore, Testorrent USA, Inc.]
* Fix display of %m in non-first argument (#7574).
Verilator 5.048 2026-04-26

View File

@ -2362,8 +2362,18 @@ public:
return nullptr;
}
bool formatScopeTracking() const { // Track scopeNamep(); Ok if false positive
return exprFormat() || name().find("%m") != string::npos
|| name().find("%M") != string::npos;
if (exprFormat() || name().find("%m") != string::npos || name().find("%M") != string::npos)
return true;
for (const AstNode* exprp = this->exprsp(); exprp; exprp = exprp->nextp()) {
if (const AstConst* const fmtp = VN_CAST(exprp, Const)) {
if (fmtp->num().isFromString()) {
const string str = fmtp->num().toString();
if (str.find("%m") != string::npos || str.find("%M") != string::npos)
return true;
}
}
}
return false;
}
bool hidden() const { return m_hidden; }
bool exprFormat() const { return m_exprFormat; }

View File

@ -106,4 +106,6 @@ XXXx
[0] not-fmt %-d 60
[0] fmt-as-string-not-%0x 70
s=[0] fmt-string-not-%s
atop.t
12top.ttop.t
*-* All Finished *-*

View File

@ -230,6 +230,10 @@ multiline", $time);
s = $sformatf("[%0t] %s", $time, " fmt-string-not-%s");
$display("s=%s", s);
// Issue #7574
$display("a", "%m");
$display(nine, "%m", "%M");
$write("*-* All Finished *-*\n");
$finish;
end

View File

@ -72,6 +72,9 @@ module t (
$swrite(str2, "mod=%m");
`checks(str2, "mod=top.t");
$swrite(str2, "n=%0d mod=%m n=%0d mod_again=%m", 1, 2);
`checks(str2, "n=1 mod=top.t n=2 mod_again=top.t");
$swrite(str2, "lib=%l");
`checks(str2, "lib=work.t");