diff --git a/src/V3EmitCFunc.h b/src/V3EmitCFunc.h index f4e72f380..fa9a3d157 100644 --- a/src/V3EmitCFunc.h +++ b/src/V3EmitCFunc.h @@ -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 { diff --git a/test_regress/t/t_class_new.v b/test_regress/t/t_class_new.v index 811693dc5..4e1ff9f48 100644 --- a/test_regress/t/t_class_new.v +++ b/test_regress/t/t_class_new.v @@ -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