Add regression test for const properties in derived classes

Check that an inherited property does not offset initialization bookkeeping
for a const property assigned in the derived class constructor.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-08-06 22:23:15 -07:00
parent 6e2c7f352e
commit bfc0121fb9
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,29 @@
// Check const property initialization in a derived class.
module test;
class Base;
int inherited;
endclass
class Derived extends Base;
const int value;
function new;
value = 42;
endfunction
endclass
Derived object;
initial begin
object = new;
if (object.value !== 42) begin
$display("FAILED: expected 42, got %0d", object.value);
end else begin
$display("PASSED");
end
end
endmodule

View File

@ -285,6 +285,7 @@ sv_chained_constructor2 vvp_tests/sv_chained_constructor2.json
sv_chained_constructor3 vvp_tests/sv_chained_constructor3.json
sv_chained_constructor4 vvp_tests/sv_chained_constructor4.json
sv_chained_constructor5 vvp_tests/sv_chained_constructor5.json
sv_class_const_derived vvp_tests/sv_class_const_derived.json
sv_class_nested_method_call vvp_tests/sv_class_nested_method_call.json
sv_class_prop_assign_op1 vvp_tests/sv_class_prop_assign_op1.json
sv_class_prop_assign_op2 vvp_tests/sv_class_prop_assign_op2.json

View File

@ -0,0 +1,9 @@
{
"type" : "normal",
"source" : "sv_class_const_derived.v",
"iverilog-args" : [ "-g2005-sv" ],
"vlog95" : {
"__comment" : "Classes are not supported",
"type" : "CE"
}
}