From b07fb6836f345ef5859b76409e6bf2cfbb2425f6 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 7 Sep 2026 10:11:36 -0700 Subject: [PATCH] Use `dimensions` for named function return types The function-return rule `data_type_or_implicit_plus_id` parses dimensions following a named return type with `index_components_opt` and converts them to `dimensions` in its action. Use `dimensions_opt` directly, which performs the same conversion through `make_dimensions()`. This makes the index-component overload of `pform_make_parray_type()` unnecessary. Remove it together with the unused `set_type_id_range()` overload and the `nullptr` disambiguation overload. The shared port/declaration path already gets its type dimensions from `ps_type_identifier_dim`, so it needs no corresponding change. This simplifies the grammar in preparation for removing `TYPE_IDENTIFIER`. Signed-off-by: Lars-Peter Clausen --- parse.y | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/parse.y b/parse.y index cbe18aa35..156474d29 100644 --- a/parse.y +++ b/parse.y @@ -127,9 +127,6 @@ static void check_net_decl_assigns(const struct vlltype&loc, } } -static std::list * -make_dimensions(std::list *components); - static data_type_t *pform_make_parray_type(const struct vlltype&loc, data_type_t *base, std::list *pdims) @@ -143,14 +140,6 @@ static data_type_t *pform_make_parray_type(const struct vlltype&loc, return type; } -static data_type_t *pform_make_parray_type( - const struct vlltype &loc, - data_type_t *base, - std::list *components) -{ - return pform_make_parray_type(loc, base, make_dimensions(components)); -} - template static void set_type_id_range(T&value, data_type_t *type, char *id, const YYLTYPE&loc, @@ -162,22 +151,6 @@ static void set_type_id_range(T&value, data_type_t *type, char *id, value.ranges = ranges; } -template -static void set_type_id_range(T &value, data_type_t *type, char *id, - const YYLTYPE &loc, - std::list *components) -{ - set_type_id_range(value, type, id, loc, make_dimensions(components)); -} - -template -static void set_type_id_range(T &value, data_type_t *type, char *id, - const YYLTYPE &loc, std::nullptr_t) -{ - set_type_id_range(value, type, id, loc, - static_cast *>(nullptr)); -} - template static void delete_type_id_range(T&value) { @@ -3057,7 +3030,7 @@ data_type_or_implicit_plus_id : identifier_name { set_type_id_range($$, nullptr, $1, @1, nullptr); } - | identifier_name index_components_opt identifier_name + | identifier_name dimensions_opt identifier_name { if (!gn_system_verilog()) { yyerror(@1, "syntax error"); delete[]$1;