From 03c4c63df1223c0499e5bd9bc70315aa0c760b3c Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 27 Sep 2019 00:46:39 +0100 Subject: [PATCH] Fix file/line reported for duplicate named blocks. --- parse.y | 18 ++++++------------ pform.cc | 4 +++- pform.h | 3 ++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/parse.y b/parse.y index 28154625a..822f02e83 100644 --- a/parse.y +++ b/parse.y @@ -1414,8 +1414,7 @@ loop_statement /* IEEE1800-2005: A.6.8 */ char for_block_name [64]; snprintf(for_block_name, sizeof for_block_name, "$ivl_for_loop%u", for_counter); for_counter += 1; - PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ); - FILE_NAME(tmp, @1); + PBlock*tmp = pform_push_block_scope(@1, for_block_name, PBlock::BL_SEQ); current_block_stack.push(tmp); listassign_list; @@ -1476,8 +1475,7 @@ loop_statement /* IEEE1800-2005: A.6.8 */ snprintf(for_block_name, sizeof for_block_name, "$ivl_foreach%u", foreach_counter); foreach_counter += 1; - PBlock*tmp = pform_push_block_scope(for_block_name, PBlock::BL_SEQ); - FILE_NAME(tmp, @1); + PBlock*tmp = pform_push_block_scope(@1, for_block_name, PBlock::BL_SEQ); current_block_stack.push(tmp); pform_make_foreach_declarations(@1, $5); @@ -6252,8 +6250,7 @@ statement_item /* This is roughly statement_item in the LRM */ } /* In SystemVerilog an unnamed block can contain variable declarations. */ | K_begin - { PBlock*tmp = pform_push_block_scope(0, PBlock::BL_SEQ); - FILE_NAME(tmp, @1); + { PBlock*tmp = pform_push_block_scope(@1, 0, PBlock::BL_SEQ); current_block_stack.push(tmp); } block_item_decls_opt @@ -6287,8 +6284,7 @@ statement_item /* This is roughly statement_item in the LRM */ $$ = tmp; } | K_begin ':' IDENTIFIER - { PBlock*tmp = pform_push_block_scope($3, PBlock::BL_SEQ); - FILE_NAME(tmp, @1); + { PBlock*tmp = pform_push_block_scope(@1, $3, PBlock::BL_SEQ); current_block_stack.push(tmp); } block_item_decls_opt @@ -6325,8 +6321,7 @@ statement_item /* This is roughly statement_item in the LRM */ } /* 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); + { PBlock*tmp = pform_push_block_scope(@1, 0, PBlock::BL_PAR); current_block_stack.push(tmp); } block_item_decls_opt @@ -6361,8 +6356,7 @@ statement_item /* This is roughly statement_item in the LRM */ $$ = tmp; } | K_fork ':' IDENTIFIER - { PBlock*tmp = pform_push_block_scope($3, PBlock::BL_PAR); - FILE_NAME(tmp, @1); + { PBlock*tmp = pform_push_block_scope(@1, $3, PBlock::BL_PAR); current_block_stack.push(tmp); } block_item_decls_opt diff --git a/pform.cc b/pform.cc index c0a57ffcc..17ad83d60 100644 --- a/pform.cc +++ b/pform.cc @@ -696,7 +696,8 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, const char*name, return func; } -PBlock* pform_push_block_scope(char*name, PBlock::BL_TYPE bt) +PBlock* pform_push_block_scope(const struct vlltype&loc, char*name, + PBlock::BL_TYPE bt) { perm_string block_name; if (name) block_name = lex_strings.make(name); @@ -710,6 +711,7 @@ PBlock* pform_push_block_scope(char*name, PBlock::BL_TYPE bt) } PBlock*block = new PBlock(block_name, lexical_scope, bt); + FILE_NAME(block, loc); block->default_lifetime = find_lifetime(LexicalScope::INHERITED); if (name) add_local_symbol(lexical_scope, block_name, block); lexical_scope = block; diff --git a/pform.h b/pform.h index cd1fb5c88..f538e58a7 100644 --- a/pform.h +++ b/pform.h @@ -274,7 +274,8 @@ extern PTask*pform_push_task_scope(const struct vlltype&loc, char*name, extern PFunction*pform_push_function_scope(const struct vlltype&loc, const char*name, LexicalScope::lifetime_t lifetime); -extern PBlock*pform_push_block_scope(char*name, PBlock::BL_TYPE tt); +extern PBlock*pform_push_block_scope(const struct vlltype&loc, char*name, + PBlock::BL_TYPE tt); extern void pform_put_behavior_in_scope(AProcess*proc);