From c76db2867c10452e9efba3079d11d685d95f60e5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 6 Feb 2022 18:24:24 +0100 Subject: [PATCH] Allow any data type in primary expression There are a few system functions that take either an expression or a data type. This is implemented in the parser by allowing a type identifier as a primary expression. But those functions allow any data type, not just typedefs. E.g. ``` $bits(int); $bits(reg [1:0]); $bits(struct packed { int x; }); ``` Support this by changing the parser rule from TYPE_IDENTIFIER to data_type. Signed-off-by: Lars-Peter Clausen --- parse.y | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/parse.y b/parse.y index 4850a0611..06bfa669b 100644 --- a/parse.y +++ b/parse.y @@ -3760,12 +3760,10 @@ expr_primary_or_typename /* There are a few special cases (notably $bits argument) where the expression may be a type name. Let the elaborator sort this out. */ - | TYPE_IDENTIFIER - { pform_set_type_referenced(@1, $1.text); - PETypename*tmp = new PETypename($1.type); - FILE_NAME(tmp,@1); + | data_type + { PETypename*tmp = new PETypename($1); + FILE_NAME(tmp, @1); $$ = tmp; - delete[]$1.text; } ;