From 0cbd6d99af7176f884b3f7523c785cdfbafd152b Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 23 Jul 2014 09:50:18 -0700 Subject: [PATCH] SV: Add support for var decls in unnamed fork/join* blocks. SystemVerilog allows variables to be declared in unnamed fork/join* blocks. This patch adds support for this functionality. --- parse.y | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/parse.y b/parse.y index 9dc46e859..64716c371 100644 --- a/parse.y +++ b/parse.y @@ -5702,14 +5702,41 @@ statement_item /* This is roughly statement_item in the LRM */ FILE_NAME(tmp, @1); $$ = tmp; } - | K_fork statement_or_null_list join_keyword -// HERE -// Create an anonymous scope and if no definitions are found then delete -// the scope and use a simple block. - { PBlock*tmp = new PBlock($3); + /* In SystemVerilog an unnamed block can contain variable declarations. */ + | K_fork + { PBlock*tmp = pform_push_block_scope(0, PBlock::BL_PAR); FILE_NAME(tmp, @1); - tmp->set_statement(*$2); - delete $2; + current_block_stack.push(tmp); + } + block_item_decls_opt + { if ($3) { + if (! gn_system_verilog()) { + yyerror("error: Variable declaration in unnamed block " + "requires SystemVerilog."); + } + } else { + /* If there are no declarations in the scope then just delete it. */ + pform_pop_scope(); + assert(! current_block_stack.empty()); + PBlock*tmp = current_block_stack.top(); + current_block_stack.pop(); + delete tmp; + } + } + statement_or_null_list join_keyword + { PBlock*tmp; + if ($3) { + pform_pop_scope(); + assert(! current_block_stack.empty()); + tmp = current_block_stack.top(); + current_block_stack.pop(); + tmp->set_join_type($6); + } else { + tmp = new PBlock($6); + FILE_NAME(tmp, @1); + } + if ($5) tmp->set_statement(*$5); + delete $5; $$ = tmp; } | K_fork ':' IDENTIFIER