Fix file/line reported for duplicate named blocks.

This commit is contained in:
Martin Whitaker 2019-09-27 00:46:39 +01:00
parent 628f5645bf
commit 03c4c63df1
3 changed files with 11 additions and 14 deletions

18
parse.y
View File

@ -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);
list<decl_assignment_t*>assign_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

View File

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

View File

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