From bfc0121fb95430ae953ccdfae0b0e038858d93dd Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 6 Aug 2026 22:23:15 -0700 Subject: [PATCH] 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 --- ivtest/ivltests/sv_class_const_derived.v | 29 ++++++++++++++++++++ ivtest/regress-vvp.list | 1 + ivtest/vvp_tests/sv_class_const_derived.json | 9 ++++++ 3 files changed, 39 insertions(+) create mode 100644 ivtest/ivltests/sv_class_const_derived.v create mode 100644 ivtest/vvp_tests/sv_class_const_derived.json diff --git a/ivtest/ivltests/sv_class_const_derived.v b/ivtest/ivltests/sv_class_const_derived.v new file mode 100644 index 000000000..41c47b765 --- /dev/null +++ b/ivtest/ivltests/sv_class_const_derived.v @@ -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 diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 5453cb1ca..9d338fd9b 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -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 diff --git a/ivtest/vvp_tests/sv_class_const_derived.json b/ivtest/vvp_tests/sv_class_const_derived.json new file mode 100644 index 000000000..8ce6acca9 --- /dev/null +++ b/ivtest/vvp_tests/sv_class_const_derived.json @@ -0,0 +1,9 @@ +{ + "type" : "normal", + "source" : "sv_class_const_derived.v", + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "Classes are not supported", + "type" : "CE" + } +}