Add regression tests for invalid index component contexts

Consolidating variable dimensions and hierarchy indices into a shared
grammar makes all index component forms parse in either context.

Check that `+:` and `-:` indexed part selects are rejected as dimensions,
and that `[]` and `[$:N]` are rejected as hierarchy indices. These forms
were previously excluded by the context-specific grammar rules.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2026-08-08 19:06:22 -07:00
parent cb3bf494f2
commit 2efe188b52
9 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,5 @@
// Check that a descending indexed part select is not a dimension.
module test;
reg value[1 -: 2];
endmodule

View File

@ -0,0 +1,5 @@
// Check that an ascending indexed part select is not a dimension.
module test;
reg value[0 +: 2];
endmodule

View File

@ -0,0 +1,6 @@
// Check that an empty index is not allowed in a hierarchy identifier.
module test;
reg [3:0] value;
initial $display("%b", value[]);
endmodule

View File

@ -0,0 +1,6 @@
// Check that a queue bound is not allowed in a hierarchy identifier.
module test;
reg [3:0] value;
initial $display("%b", value[$:1]);
endmodule

View File

@ -137,6 +137,8 @@ dffsynth8 vvp_tests/dffsynth8.json
dffsynth9 vvp_tests/dffsynth9.json
dffsynth10 vvp_tests/dffsynth10.json
dffsynth11 vvp_tests/dffsynth11.json
dimension_idx_down_fail vvp_tests/dimension_idx_down_fail.json
dimension_idx_up_fail vvp_tests/dimension_idx_up_fail.json
drive_strength4 vvp_tests/drive_strength4.json
dumpfile vvp_tests/dumpfile.json
early_sig_elab1 vvp_tests/early_sig_elab1.json
@ -150,6 +152,8 @@ fmonitor1 vvp_tests/fmonitor1.json
fmonitor2 vvp_tests/fmonitor2.json
fread-error vvp_tests/fread-error.json
func_nested_block_nb_fail vvp_tests/func_nested_block_nb_fail.json
hier_index_empty_fail vvp_tests/hier_index_empty_fail.json
hier_index_queue_fail vvp_tests/hier_index_queue_fail.json
line_directive vvp_tests/line_directive.json
localparam_type vvp_tests/localparam_type.json
macro_str_esc vvp_tests/macro_str_esc.json

View File

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

View File

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

View File

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

View File

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