Add additional regression tests for typedef overwrites

Check that it is possible to create a typedef of an array type that shadows
an existing typedef in a higher level scope.

Also check that it is possible to create a typedef in a class scope that
shadows an exiting typedef in a higher level scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-03-23 10:15:37 +01:00
parent b30d3fc8d7
commit 252174d15a
5 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,24 @@
// Check that it is possible to overwrite a type identifier declared in a higher
// level scope. Check that this works if the new type is an array type.
typedef logic [3:0] T;
T x;
module test;
typedef logic [7:0] T[1:0];
T y;
initial begin
y[0] = 8'hff;
y[1] = 8'hfe;
if ($bits(T) == 16 && $size(x) == 4 && $size(y) == 2 &&
y[0] == 8'hff && y[1] == 8'hfe) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,30 @@
// Check that it is possible to overwrite a type identifier declared in a higher
// level scope. Check that this works when the new type is declared in a class.
typedef logic [3:0] T;
T x;
module test;
class C;
typedef logic [7:0] T;
T y;
task t;
y = 8'hff;
if ($bits(x) == 4 && $bits(y) == 8 && y == 8'hff) begin
$display("PASSED");
end else begin
$display("FAILED");
end
endtask
endclass
C c;
initial begin
c = new;
c.t();
end
endmodule

View File

@ -568,7 +568,9 @@ sv_timeunit_prec_fail2 CE,-g2009,-u,\
./ivltests/sv_timeunit_prec_fail2a.v,\
./ivltests/sv_timeunit_prec_fail2b.v,\
./ivltests/sv_timeunit_prec_fail2c.v, ivltests gold=sv_timeunit_prec_fail2.gold
sv_typedef_scope normal,-g2009 ivltests
sv_typedef_scope1 normal,-g2009 ivltests
sv_typedef_scope2 normal,-g2009 ivltests
sv_typedef_scope3 normal,-g2009 ivltests
sv_union1 normal,-g2009 ivltests
sv_union1b normal,-g2009 ivltests
sv_union2 normal,-g2009 ivltests

View File

@ -387,6 +387,7 @@ sv_port_default7 CE,-g2009,-pallowsigned=1 ivltests
sv_port_default8 CE,-g2009,-pallowsigned=1 ivltests
sv_port_default9 CE,-g2009 ivltests
sv_root_class CE,-g2009 ivltests
sv_typedef_scope3 CE,-g2009 ivltests
sv_unit2b CE,-g2009 ivltests
sv_unit3b CE,-g2009 ivltests
sv_unit4b CE,-g2009 ivltests