From 4cc3c7b08f25a141d4352605a1a1bb5343f9ea24 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 22 Dec 2022 21:51:29 -0800 Subject: [PATCH] Add regression tests for shadowing class properties Check that class properties can be shadowed by local symbols in class methods and also check that a package scoped identifier with the same name as class property can be accessed in a class method. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_class_prop_shadow1.v | 25 ++++++++++++++++++++++ ivtest/ivltests/sv_class_prop_shadow2.v | 28 +++++++++++++++++++++++++ ivtest/regress-sv.list | 2 ++ ivtest/regress-vlog95.list | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 ivtest/ivltests/sv_class_prop_shadow1.v create mode 100644 ivtest/ivltests/sv_class_prop_shadow2.v diff --git a/ivtest/ivltests/sv_class_prop_shadow1.v b/ivtest/ivltests/sv_class_prop_shadow1.v new file mode 100644 index 000000000..00deb4685 --- /dev/null +++ b/ivtest/ivltests/sv_class_prop_shadow1.v @@ -0,0 +1,25 @@ +// Check that class properties can be shadowed by a local symbol + +module test; + + class C; + int x = 0; + + task check; + int x; // This should shadow the class property + x = 10; + if (this.x == 0 && x === 10) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + endtask + endclass + + initial begin + C c; + c = new; + c.check; + end + +endmodule diff --git a/ivtest/ivltests/sv_class_prop_shadow2.v b/ivtest/ivltests/sv_class_prop_shadow2.v new file mode 100644 index 000000000..49e4db5d7 --- /dev/null +++ b/ivtest/ivltests/sv_class_prop_shadow2.v @@ -0,0 +1,28 @@ +// Check that it is possible to access a package scoped identifier of the same +// name of a class property inside a class method + +package P; + int x = 10; +endpackage + +module test; + + class C; + int x = 0; + + task check; + if (P::x === 10) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + endtask + endclass + + initial begin + C c; + c = new; + c.check; + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 156e76d49..f25c85168 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -584,6 +584,8 @@ sv_class_method_lt_static2 CE,-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_prop_shadow1 normal,-g2009 ivltests +sv_class_prop_shadow2 normal,-g2009 ivltests sv_class_property_signed1 normal,-g2009 ivltests sv_class_property_signed2 normal,-g2009 ivltests sv_class_property_signed3 normal,-g2009 ivltests diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index 84e2bd204..f26123ae1 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -432,6 +432,8 @@ 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_prop_shadow1 CE,-g2009 ivltests +sv_class_prop_shadow2 CE,-g2009 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