Add regression test for var init in class method

Check that variable initialization as part of the declaration works as
expected in class methods.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-12-18 16:03:30 -08:00
parent 3302ced608
commit da4ac3607a
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Check that variable initialization as part of the declaration works as
// expected in class methods.
module test;
class C;
task t(bit check);
int x = 10; // The initialization should happen on each invocation
if (check) begin
if (x === 10) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
x = 20;
endtask
endclass
initial begin
C c;
c = new;
c.t(1'b0);
c.t(1'b1);
end
endmodule

View File

@ -567,6 +567,7 @@ sv_class_method_default1 normal,-g2009 ivltests
sv_class_method_default2 normal,-g2009 ivltests
sv_class_method_signed1 normal,-g2009 ivltests
sv_class_method_signed2 normal,-g2009 ivltests
sv_class_method_var_init normal,-g2009 ivltests
sv_class_property_signed1 normal,-g2009 ivltests
sv_class_property_signed2 normal,-g2009 ivltests
sv_class_property_signed3 normal,-g2009 ivltests

View File

@ -422,6 +422,7 @@ sv_class_method_default1 CE,-g2009 ivltests
sv_class_method_default2 CE,-g2009 ivltests
sv_class_method_signed1 CE,-g2009,-pallowsigned=1 ivltests
sv_class_method_signed2 CE,-g2009,-pallowsigned=1 ivltests
sv_class_method_var_init CE,-g2009,-pallowsigned=1 ivltests
sv_class_property_signed1 CE,-g2009,-pallowsigned=1 ivltests
sv_class_property_signed2 CE,-g2009,-pallowsigned=1 ivltests
sv_class_property_signed3 CE,-g2009,-pallowsigned=1 ivltests