From 2efe188b5239e96313967559985b3f2d6635fad5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 8 Aug 2026 19:06:22 -0700 Subject: [PATCH] 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 --- ivtest/ivltests/dimension_idx_down_fail.v | 5 +++++ ivtest/ivltests/dimension_idx_up_fail.v | 5 +++++ ivtest/ivltests/hier_index_empty_fail.v | 6 ++++++ ivtest/ivltests/hier_index_queue_fail.v | 6 ++++++ ivtest/regress-vvp.list | 4 ++++ ivtest/vvp_tests/dimension_idx_down_fail.json | 5 +++++ ivtest/vvp_tests/dimension_idx_up_fail.json | 5 +++++ ivtest/vvp_tests/hier_index_empty_fail.json | 5 +++++ ivtest/vvp_tests/hier_index_queue_fail.json | 5 +++++ 9 files changed, 46 insertions(+) create mode 100644 ivtest/ivltests/dimension_idx_down_fail.v create mode 100644 ivtest/ivltests/dimension_idx_up_fail.v create mode 100644 ivtest/ivltests/hier_index_empty_fail.v create mode 100644 ivtest/ivltests/hier_index_queue_fail.v create mode 100644 ivtest/vvp_tests/dimension_idx_down_fail.json create mode 100644 ivtest/vvp_tests/dimension_idx_up_fail.json create mode 100644 ivtest/vvp_tests/hier_index_empty_fail.json create mode 100644 ivtest/vvp_tests/hier_index_queue_fail.json diff --git a/ivtest/ivltests/dimension_idx_down_fail.v b/ivtest/ivltests/dimension_idx_down_fail.v new file mode 100644 index 000000000..fef8fd5d5 --- /dev/null +++ b/ivtest/ivltests/dimension_idx_down_fail.v @@ -0,0 +1,5 @@ +// Check that a descending indexed part select is not a dimension. + +module test; + reg value[1 -: 2]; +endmodule diff --git a/ivtest/ivltests/dimension_idx_up_fail.v b/ivtest/ivltests/dimension_idx_up_fail.v new file mode 100644 index 000000000..a9902016e --- /dev/null +++ b/ivtest/ivltests/dimension_idx_up_fail.v @@ -0,0 +1,5 @@ +// Check that an ascending indexed part select is not a dimension. + +module test; + reg value[0 +: 2]; +endmodule diff --git a/ivtest/ivltests/hier_index_empty_fail.v b/ivtest/ivltests/hier_index_empty_fail.v new file mode 100644 index 000000000..6a089c7bf --- /dev/null +++ b/ivtest/ivltests/hier_index_empty_fail.v @@ -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 diff --git a/ivtest/ivltests/hier_index_queue_fail.v b/ivtest/ivltests/hier_index_queue_fail.v new file mode 100644 index 000000000..b862e4663 --- /dev/null +++ b/ivtest/ivltests/hier_index_queue_fail.v @@ -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 diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index f9138fc2d..faaecce00 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -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 diff --git a/ivtest/vvp_tests/dimension_idx_down_fail.json b/ivtest/vvp_tests/dimension_idx_down_fail.json new file mode 100644 index 000000000..7c2dc41cd --- /dev/null +++ b/ivtest/vvp_tests/dimension_idx_down_fail.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "dimension_idx_down_fail.v", + "iverilog-args" : [ "-g2001" ] +} diff --git a/ivtest/vvp_tests/dimension_idx_up_fail.json b/ivtest/vvp_tests/dimension_idx_up_fail.json new file mode 100644 index 000000000..9b52557e3 --- /dev/null +++ b/ivtest/vvp_tests/dimension_idx_up_fail.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "dimension_idx_up_fail.v", + "iverilog-args" : [ "-g2001" ] +} diff --git a/ivtest/vvp_tests/hier_index_empty_fail.json b/ivtest/vvp_tests/hier_index_empty_fail.json new file mode 100644 index 000000000..58480521f --- /dev/null +++ b/ivtest/vvp_tests/hier_index_empty_fail.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "hier_index_empty_fail.v", + "iverilog-args" : [ "-g2005-sv" ] +} diff --git a/ivtest/vvp_tests/hier_index_queue_fail.json b/ivtest/vvp_tests/hier_index_queue_fail.json new file mode 100644 index 000000000..4223527b7 --- /dev/null +++ b/ivtest/vvp_tests/hier_index_queue_fail.json @@ -0,0 +1,5 @@ +{ + "type" : "CE", + "source" : "hier_index_queue_fail.v", + "iverilog-args" : [ "-g2005-sv" ] +}