diff --git a/ivtest/ivltests/sv_ps_function1.v b/ivtest/ivltests/sv_ps_function1.v new file mode 100644 index 000000000..17edbb7a4 --- /dev/null +++ b/ivtest/ivltests/sv_ps_function1.v @@ -0,0 +1,20 @@ +// Check that it is possible to call a package scoped function. + +package P; + function integer T(integer x, integer y); + return x + y; + endfunction +endpackage + +module test; + initial begin + integer x; + x = P::T(1, 2); + if (x === 3) begin + $display("PASSED"); + end else begin + $display("FAILED. x = %d, expected 3", x); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ps_function2.v b/ivtest/ivltests/sv_ps_function2.v new file mode 100644 index 000000000..cd6c7b7f6 --- /dev/null +++ b/ivtest/ivltests/sv_ps_function2.v @@ -0,0 +1,21 @@ +// Check that it is possible to call a package scoped function with no +// arguments. + +package P; + function integer T(); + return 1; + endfunction +endpackage + +module test; + initial begin + integer x; + x = P::T(); + if (x === 1) begin + $display("PASSED"); + end else begin + $display("FAILED: x = %d, expected 1", x); + end + end + +endmodule diff --git a/ivtest/ivltests/sv_ps_function3.v b/ivtest/ivltests/sv_ps_function3.v new file mode 100644 index 000000000..92d45a1c3 --- /dev/null +++ b/ivtest/ivltests/sv_ps_function3.v @@ -0,0 +1,21 @@ +// Check that it is possible to call a package scoped function with empty +// positional arguments. + +package P; + function integer T(integer x = 1, integer y = 2); + return x + y; + endfunction +endpackage + +module test; + initial begin + integer x; + x = P::T(, 4); + if (x === 5) begin + $display("PASSED"); + end else begin + $display("FAILED. x = %d, expected 5", x); + end + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index c35f5bc08..9e133585b 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -615,6 +615,9 @@ sv_port_default11 normal,-g2009 ivltests sv_port_default12 normal,-g2009 ivltests sv_port_default13 CE,-g2009 ivltests sv_port_default14 CE,-g2009 ivltests +sv_ps_function1 normal,-g2009 ivltests +sv_ps_function2 normal,-g2009 ivltests +sv_ps_function3 normal,-g2009 ivltests sv_queue1 normal,-g2009 ivltests sv_queue2 normal,-g2009 ivltests sv_queue3 normal,-g2009 ivltests diff --git a/parse.y b/parse.y index 7ece997e1..5e41f7e69 100644 --- a/parse.y +++ b/parse.y @@ -3704,6 +3704,7 @@ expr_primary PECallFunction*tmp = pform_make_call_function(@1, *$1, *expr_list); delete $1; delete $2; + delete expr_list; $$ = tmp; } | class_hierarchy_identifier '(' expression_list_with_nuls ')' @@ -3711,6 +3712,7 @@ expr_primary strip_tail_items(expr_list); PECallFunction*tmp = pform_make_call_function(@1, *$1, *expr_list); delete $1; + delete expr_list; $$ = tmp; } | SYSTEM_IDENTIFIER '(' expression_list_proper ')' @@ -3718,13 +3720,15 @@ expr_primary PECallFunction*tmp = new PECallFunction(tn, *$3); FILE_NAME(tmp, @1); delete[]$1; + delete $3; $$ = tmp; } - | PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '(' expression_list_proper ')' + | PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '(' expression_list_with_nuls ')' { perm_string use_name = lex_strings.make($3); PECallFunction*tmp = new PECallFunction($1, use_name, *$5); FILE_NAME(tmp, @3); delete[]$3; + delete $5; $$ = tmp; } | SYSTEM_IDENTIFIER '(' ')'