Add regression tests for invalid size casts

Check that an error is reported for size casts with either a value of 0, a
negative value or an undefined value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-12-25 19:21:15 -08:00
parent 4436dc41ab
commit 5685eac1be
4 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// Check that an error is reported when using a zero value for a size cast.
module test;
localparam integer N = 0;
initial begin
int x, y;
y = N'(x); // This should fail, N is zero
end
endmodule

View File

@ -0,0 +1,12 @@
// Check that an error is reported when using a negative value for a size cast.
module test;
localparam integer N = -1;
initial begin
int x, y;
y = N'(x); // This should fail, N is negative
end
endmodule

View File

@ -0,0 +1,12 @@
// Check that an error is reported when using an undefined value for a size cast.
module test;
localparam integer N = 32'hx;
initial begin
int x, y;
y = N'(x); // This should fail, N is undefined
end
endmodule

View File

@ -465,6 +465,9 @@ size_cast2 normal,-g2005-sv ivltests
size_cast3 normal,-g2009 ivltests
size_cast4 normal,-g2009 ivltests
size_cast5 normal,-g2009 ivltests
size_cast_fail1 CE,-g2009 ivltests
size_cast_fail2 CE,-g2009 ivltests
size_cast_fail3 CE,-g2009 ivltests
slongint_test normal,-g2005-sv ivltests
sshortint_test normal,-g2005-sv ivltests
string_events normal,-g2009 ivltests gold=string_events.gold