Add regression test for access to static property of base class

Check that it is possible to access a static property of a base class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-10-07 23:23:55 +02:00
parent 8a807695e5
commit c8044bddf0
3 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,45 @@
// Check that it is possible to access static properties of a base class
class B;
static int x = 0;
static int y = 0;
endclass
class C extends B;
task t(int a, int b);
x = a;
this.y = b;
endtask
function int f;
return x + this.y;
endfunction
endclass
module test;
bit failed = 1'b0;
`define check(expr, val) \
if (expr !== val) begin \
$display("FAILED: `%s`, expected %b, got %b", `"expr`", val, expr); \
failed = 1'b1; \
end
C c = new;
initial begin
// Check access inside the class
c.t(10, 20);
`check(c.f(), 30)
// Check access outside of the class
c.x = 40;
`check(c.x, 40)
if (!failed) begin
$display("PASSED");
end
end
endmodule

View File

@ -590,6 +590,7 @@ sv_class_return normal,-g2009 ivltests
sv_class_static_prop1 normal,-g2009 ivltests
sv_class_static_prop2 normal,-g2009 ivltests
sv_class_static_prop3 normal,-g2009 ivltests
sv_class_static_prop4 normal,-g2009 ivltests
sv_class_super1 normal,-g2009 ivltests
sv_class_super2 normal,-g2009 ivltests
sv_class_super3 normal,-g2009 ivltests

View File

@ -437,6 +437,7 @@ sv_class_return CE,-g2009 ivltests
sv_class_static_prop1 CE,-g2009 ivltests
sv_class_static_prop2 CE,-g2009 ivltests
sv_class_static_prop3 CE,-g2009 ivltests
sv_class_static_prop4 CE,-g2009 ivltests
sv_class_super1 CE,-g2009 ivltests
sv_class_super2 CE,-g2009 ivltests
sv_class_super3 CE,-g2009 ivltests