Add regression tests for invalid casts to real

Check that invalid casts to real are reported as an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2025-01-12 20:18:20 -08:00
parent 4c03ac5b36
commit eb90bcf313
9 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// Check that casting a string to real generates an error.
module test;
real r;
string s;
initial begin
r = real'(s); // Error: Cast from string to real not allowed
end
endmodule

View File

@ -0,0 +1,12 @@
// Check that casting a array to real generates an error.
module test;
real r;
real a[10];
initial begin
r = real'(a); // Error: Cast from array to real not allowed
end
endmodule

View File

@ -0,0 +1,12 @@
// Check that casting a queue to real generates an error.
module test;
real r;
real q[$];
initial begin
r = real'(q); // Error: Cast from queue to real not allowed
end
endmodule

View File

@ -0,0 +1,12 @@
// Check that casting a dynamic array to real generates an error.
module test;
real r;
real d[];
initial begin
r = real'(d); // Error: Cast from dynamic array to real not allowed
end
endmodule

View File

@ -72,6 +72,10 @@ case3 vvp_tests/case3.json
casex_synth vvp_tests/casex_synth.json
cast_int_ams vvp_tests/cast_int_ams.json
cast_int_ams-vlog95 vvp_tests/cast_int_ams-vlog95.json
cast_real_invalid1 vvp_tests/cast_real_invalid1.json
cast_real_invalid2 vvp_tests/cast_real_invalid2.json
cast_real_invalid3 vvp_tests/cast_real_invalid3.json
cast_real_invalid4 vvp_tests/cast_real_invalid4.json
comment1 vvp_tests/comment1.json
constfunc4_ams vvp_tests/constfunc4_ams.json
constfunc4_ams-vlog95 vvp_tests/constfunc4_ams-vlog95.json

View File

@ -0,0 +1,5 @@
{
"type" : "CE",
"source" : "cast_real_invalid1.v",
"iverilog-args" : [ "-g2005-sv" ]
}

View File

@ -0,0 +1,5 @@
{
"type" : "CE",
"source" : "cast_real_invalid2.v",
"iverilog-args" : [ "-g2005-sv" ]
}

View File

@ -0,0 +1,5 @@
{
"type" : "CE",
"source" : "cast_real_invalid3.v",
"iverilog-args" : [ "-g2005-sv" ]
}

View File

@ -0,0 +1,5 @@
{
"type" : "CE",
"source" : "cast_real_invalid4.v",
"iverilog-args" : [ "-g2005-sv" ]
}