mirror of
https://github.com/verilator/verilator.git
synced 2025-05-02 21:46:54 +00:00
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, "");
|
emitCCallArgs(nodep, "");
|
||||||
}
|
}
|
||||||
virtual void visit(AstCNew* nodep) override {
|
virtual void visit(AstCNew* nodep) override {
|
||||||
|
bool comma = false;
|
||||||
puts("std::make_shared<" + prefixNameProtect(nodep->dtypep()) + ">(");
|
puts("std::make_shared<" + prefixNameProtect(nodep->dtypep()) + ">(");
|
||||||
puts("vlSymsp"); // TODO make this part of argsp, and eliminate when unnecessary
|
puts("vlSymsp"); // TODO make this part of argsp, and eliminate when unnecessary
|
||||||
if (nodep->argsp()) puts(", ");
|
if (nodep->argsp()) comma = true;
|
||||||
iterateAndNextNull(nodep->argsp());
|
for (AstNode* subnodep = nodep->argsp(); subnodep; subnodep = subnodep->nextp()) {
|
||||||
|
if (comma) puts(", ");
|
||||||
|
iterate(subnodep);
|
||||||
|
comma = true;
|
||||||
|
}
|
||||||
puts(")");
|
puts(")");
|
||||||
}
|
}
|
||||||
virtual void visit(AstCMethodHard* nodep) override {
|
virtual void visit(AstCMethodHard* nodep) override {
|
||||||
|
@ -26,10 +26,20 @@ class ClsArg;
|
|||||||
endfunction
|
endfunction
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
|
class Cls2Arg;
|
||||||
|
int imembera;
|
||||||
|
int imemberb;
|
||||||
|
function new(int i, int j);
|
||||||
|
imembera = i + 1;
|
||||||
|
imemberb = j + 2;
|
||||||
|
endfunction
|
||||||
|
endclass
|
||||||
|
|
||||||
module t (/*AUTOARG*/);
|
module t (/*AUTOARG*/);
|
||||||
initial begin
|
initial begin
|
||||||
ClsNoArg c1;
|
ClsNoArg c1;
|
||||||
ClsArg c2;
|
ClsArg c2;
|
||||||
|
Cls2Arg c3;
|
||||||
|
|
||||||
c1 = new;
|
c1 = new;
|
||||||
if (c1.imembera != 5) $stop;
|
if (c1.imembera != 5) $stop;
|
||||||
@ -42,6 +52,10 @@ module t (/*AUTOARG*/);
|
|||||||
if (c2.imembera != 6) $stop;
|
if (c2.imembera != 6) $stop;
|
||||||
if (c2.geta() != 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");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user