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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-03-22 12:00:54 +01:00
parent b3f7ce6020
commit 23e1143ad6
1 changed files with 3 additions and 3 deletions

View File

@ -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;
}