Support block labels shadowing type identifiers
SystemVerilog allows a named block label in an inner scope to use the same
name as a visible type identifier from an outer scope. The lexer reports such
names as `TYPE_IDENTIFIER` before the label has been installed, which made
constructs such as:
typedef int T;
module test;
initial begin
begin : T
end : T
end
endmodule
fail in the block label grammar.
The affected grammar positions are label names, not declarations with an
adjacent type/name ambiguity. Use `identifier_name` for `label_opt` and for the
anachronistic named generate begin form so a token returned as `TYPE_IDENTIFIER`
can still be accepted as the label name. With `label_opt` able to handle
`TYPE_IDENTIFIER`, the separate class end-label rule is no longer needed.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
15277c9fa4
commit
06740d0dda
16
parse.y
16
parse.y
|
|
@ -879,7 +879,7 @@ Module::port_t *module_declare_interface_port(const YYLTYPE&loc, char *type,
|
|||
%type <wires> udp_port_decl udp_port_decls
|
||||
%type <statement> udp_initial udp_init_opt
|
||||
|
||||
%type <text> event_variable label_opt class_declaration_endlabel_opt
|
||||
%type <text> event_variable label_opt
|
||||
%type <text> block_identifier_opt
|
||||
%type <text> identifier_name
|
||||
%type <identifiers> event_variable_list
|
||||
|
|
@ -1126,7 +1126,7 @@ class_declaration /* IEEE1800-2005: A.1.2 */
|
|||
{ // Process a class.
|
||||
pform_end_class_declaration(@9);
|
||||
}
|
||||
class_declaration_endlabel_opt
|
||||
label_opt
|
||||
{ // Wrap up the class.
|
||||
check_end_label(@11, "class", $4, $11);
|
||||
delete[] $4;
|
||||
|
|
@ -1145,14 +1145,6 @@ identifier_name
|
|||
| TYPE_IDENTIFIER { $$ = $1.text; }
|
||||
;
|
||||
|
||||
/* The endlabel after a class declaration is a little tricky because
|
||||
the class name is detected by the lexor as a TYPE_IDENTIFIER if it
|
||||
does indeed match a name. */
|
||||
class_declaration_endlabel_opt
|
||||
: ':' identifier_name { $$ = $2; }
|
||||
| { $$ = 0; }
|
||||
;
|
||||
|
||||
/* This rule implements [ extends class_type ] in the
|
||||
class_declaration. It is not a rule of its own in the LRM.
|
||||
|
||||
|
|
@ -5217,7 +5209,7 @@ module_end
|
|||
;
|
||||
|
||||
label_opt
|
||||
: ':' IDENTIFIER { $$ = $2; }
|
||||
: ':' identifier_name { $$ = $2; }
|
||||
| { $$ = 0; }
|
||||
;
|
||||
|
||||
|
|
@ -5787,7 +5779,7 @@ generate_item
|
|||
cerr << @1 << ": warning: Anachronistic use of begin/end to surround generate schemes." << endl;
|
||||
}
|
||||
}
|
||||
| K_begin ':' IDENTIFIER
|
||||
| K_begin ':' identifier_name
|
||||
{ pform_start_generate_nblock(@1, $3); }
|
||||
generate_item_list_opt K_end
|
||||
{ /* Detect and warn about anachronistic named begin/end use */
|
||||
|
|
|
|||
Loading…
Reference in New Issue