From 23e1143ad6870f35aee093f6bc930331a1c4882a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 22 Mar 2022 12:00:54 +0100 Subject: [PATCH] Support unpacked dimensions on typedef overwrites It is possible to declare a new typedef that shadows an existing typedef in a higher level scope. E.g. ``` typedef int T; module M; typedef real T; endmodule ``` In the current implementation this only works as long as the new type is a not an array type. Update the parser to allow to specify unpacked dimension when overwriting a typedef from a different scope. Signed-off-by: Lars-Peter Clausen --- parse.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parse.y b/parse.y index dc4938e7d..eb479697a 100644 --- a/parse.y +++ b/parse.y @@ -2685,13 +2685,13 @@ type_declaration /* If the IDENTIFIER already is a typedef, it is possible for this code to override the definition, but only if the typedef is inherited from a different scope. */ - | K_typedef data_type TYPE_IDENTIFIER ';' + | K_typedef data_type TYPE_IDENTIFIER dimensions_opt ';' { perm_string name = lex_strings.make($3.text); if (pform_test_type_identifier_local(name)) { yyerror(@3, "error: Typedef identifier \"%s\" is already a type name.", $3.text); - + delete $4; } else { - pform_set_typedef(name, $2, NULL); + pform_set_typedef(name, $2, $4); } delete[]$3.text; }