Fix false error on new const assignment (#4098).

This commit is contained in:
Wilson Snyder 2023-04-09 19:46:47 -04:00
parent e3bdae77a0
commit 2ab34b5eeb
3 changed files with 8 additions and 2 deletions

View File

@ -39,6 +39,7 @@ Verilator 5.009 devel
* Fix false LATCH warning on --assert 'unique else if' (#4033) ($4054). [Jesse Taube]
* Fix characters from DEFENV literals for conda (#4035) (#4044). [Tim Snyder]
* Fix interface generate begin (#4065). [Srinivasan Venkataramanan]
* Fix false error on new const assignment (#4098). [Tudor Timi]
* Fix false ENUMVALUE on expressions and arrays.
* Fix unnecessary verilated_std.sv waivers in --waiver-output.

View File

@ -5287,6 +5287,8 @@ private:
// Function hasn't been widthed, so make it so.
// Would use user1 etc, but V3Width called from too many places to spend a user
nodep->doingWidth(true);
VL_RESTORER(m_funcp);
VL_RESTORER(m_ftaskp);
m_ftaskp = nodep;
// First width the function variable, as if is a recursive function we need data type
if (nodep->fvarp()) userIterate(nodep->fvarp(), nullptr);
@ -5306,8 +5308,6 @@ private:
nodep->didWidth(true);
nodep->doingWidth(false);
m_funcp = nullptr;
m_ftaskp = nullptr;
if (nodep->dpiImport() && !nodep->dpiOpenParent() && markHasOpenArray(nodep)) {
nodep->dpiOpenParentInc(); // Mark so V3Task will wait for a child to build calling
// func

View File

@ -7,8 +7,13 @@
class ClsNoArg;
const int imembera; // Ok for new() to assign to a const
function new();
int other = other_func();
imembera = 5;
if (other != 6) $stop;
endfunction : new
function int other_func();
return 6;
endfunction
endclass
class ClsArg;