forked from github/verilator
Fix constructor-parameter argument comma-separation in C++ (#3162)
This commit is contained in:
parent
5f597dd9fc
commit
a9646cf45c
@ -392,10 +392,15 @@ public:
|
||||
emitCCallArgs(nodep, "");
|
||||
}
|
||||
virtual void visit(AstCNew* nodep) override {
|
||||
bool comma = false;
|
||||
puts("std::make_shared<" + prefixNameProtect(nodep->dtypep()) + ">(");
|
||||
puts("vlSymsp"); // TODO make this part of argsp, and eliminate when unnecessary
|
||||
if (nodep->argsp()) puts(", ");
|
||||
iterateAndNextNull(nodep->argsp());
|
||||
if (nodep->argsp()) comma = true;
|
||||
for (AstNode* subnodep = nodep->argsp(); subnodep; subnodep = subnodep->nextp()) {
|
||||
if (comma) puts(", ");
|
||||
iterate(subnodep);
|
||||
comma = true;
|
||||
}
|
||||
puts(")");
|
||||
}
|
||||
virtual void visit(AstCMethodHard* nodep) override {
|
||||
|
@ -26,10 +26,20 @@ class ClsArg;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
class Cls2Arg;
|
||||
int imembera;
|
||||
int imemberb;
|
||||
function new(int i, int j);
|
||||
imembera = i + 1;
|
||||
imemberb = j + 2;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
initial begin
|
||||
ClsNoArg c1;
|
||||
ClsArg c2;
|
||||
ClsArg c2;
|
||||
Cls2Arg c3;
|
||||
|
||||
c1 = new;
|
||||
if (c1.imembera != 5) $stop;
|
||||
@ -42,6 +52,10 @@ module t (/*AUTOARG*/);
|
||||
if (c2.imembera != 6) $stop;
|
||||
if (c2.geta() != 6) $stop;
|
||||
|
||||
c3 = new(4, 5);
|
||||
if (c3.imembera != 5) $stop;
|
||||
if (c3.imemberb != 7) $stop;
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user