Skip to content

Commit c5c001f

Browse files
authored
Merge pull request #324 from diffblue/typedef2-fix
Verilog: fix scope created for functions
2 parents c7cd6a6 + c4fba80 commit c5c001f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

regression/verilog/typedef/typedef2.sv

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,27 @@ module main();
55

66
// as 'module_item'
77
typedef bit my_type2;
8+
my_type2 my_type2_var;
89

910
function some_function;
1011
// as 'block_item'
1112
typedef bit my_type3;
1213
begin
14+
my_type3 my_type3_var;
1315
end
1416
endfunction
1517

18+
task some_task;
19+
// as 'block_item'
20+
typedef bit my_type4;
21+
begin
22+
my_type4 my_type4_var;
23+
end
24+
endtask
25+
26+
always @my_type2_var begin : named_block
27+
typedef bit my_type5;
28+
my_type5 my_type5_var;
29+
end
30+
1631
endmodule

src/verilog/parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ function_declaration:
17061706
TOK_FUNCTION
17071707
automatic_opt signing_opt range_or_type_opt
17081708
function_identifier
1709-
{ push_scope(stack_expr($1).get(ID_identifier), "."); }
1709+
{ push_scope(stack_expr($5).get(ID_identifier), "."); }
17101710
list_of_ports_opt ';'
17111711
tf_item_declaration_brace statement
17121712
TOK_ENDFUNCTION

0 commit comments

Comments
 (0)