Fix calling new with arguments in same class (#3166).

This commit is contained in:
Wilson Snyder 2021-10-12 21:22:59 -04:00
parent c3bec344a4
commit b64e89f7ed
4 changed files with 17 additions and 4 deletions

View File

@ -23,6 +23,7 @@ Verilator 4.213 devel
* Fix crash on clang 12/13 (#3148). [Kouping Hsu]
* Fix cygwin compile error due to missing -std=gnu++14 (#3149). [Sun Kim]
* Fix missing install of vl_file_copy/vl_hier_graph (#3165). [Popolon]
* Fix calling new with arguments in same class (#3166). [Matthew Ballance]
Verilator 4.212 2021-09-01

View File

@ -3191,7 +3191,7 @@ private:
}
virtual void visit(AstNew* nodep) override {
if (nodep->didWidthAndSet()) return;
if (nodep->didWidth()) return;
AstClassRefDType* refp
= m_vup ? VN_CAST(m_vup->dtypeNullSkipRefp(), ClassRefDType) : nullptr;
if (!refp) { // e.g. int a = new;

View File

@ -33,6 +33,12 @@ class Cls2Arg;
imembera = i + 1;
imemberb = j + 2;
endfunction
function Cls2Arg clone();
Cls2Arg ret;
ret = new(imembera, imemberb);
return ret;
endfunction
endclass
module t (/*AUTOARG*/);
@ -40,6 +46,7 @@ module t (/*AUTOARG*/);
ClsNoArg c1;
ClsArg c2;
Cls2Arg c3;
Cls2Arg c4;
c1 = new;
if (c1.imembera != 5) $stop;
@ -56,6 +63,10 @@ module t (/*AUTOARG*/);
if (c3.imembera != 5) $stop;
if (c3.imemberb != 7) $stop;
c4 = c3.clone();
if (c4.imembera != 6) $stop;
if (c4.imemberb != 9) $stop;
$write("*-* All Finished *-*\n");
$finish;
end

View File

@ -1,12 +1,13 @@
%Error: t/t_class_new_bad.v:31:16: Too many arguments in function call to FUNC 'new'
: ... In instance t
31 | c1 = new(3);
| ^
%Error: t/t_class_new_bad.v:32:16: Too many arguments in function call to FUNC 'new'
: ... In instance t
32 | c2 = new(3);
| ^
%Error: t/t_class_new_bad.v:33:12: Missing argument on non-defaulted argument 'i' in function call to FUNC 'new'
: ... In instance t
33 | c3 = new();
| ^~~
%Error: Internal Error: t/t_class_new_bad.v:33:12: ../V3Broken.cpp:#: Width != WidthMin
33 | c3 = new();
| ^~~
%Error: Exiting due to