@@ -1937,10 +1937,6 @@ Label*
1937
1937
Gogo::add_label_definition (const std::string& label_name,
1938
1938
Location location)
1939
1939
{
1940
- // A label with a blank identifier is never declared or defined.
1941
- if (label_name == " _" )
1942
- return NULL ;
1943
-
1944
1940
go_assert (!this ->functions_ .empty ());
1945
1941
Function* func = this ->functions_ .back ().function ->func_value ();
1946
1942
Label* label = func->add_label_definition (this , label_name, location);
@@ -4724,7 +4720,13 @@ Function::add_label_definition(Gogo* gogo, const std::string& label_name,
4724
4720
std::pair<Labels::iterator, bool > ins =
4725
4721
this ->labels_ .insert (std::make_pair (label_name, lnull));
4726
4722
Label* label;
4727
- if (ins.second )
4723
+ if (label_name == " _" )
4724
+ {
4725
+ label = Label::create_dummy_label ();
4726
+ if (ins.second )
4727
+ ins.first ->second = label;
4728
+ }
4729
+ else if (ins.second )
4728
4730
{
4729
4731
// This is a new label.
4730
4732
label = new Label (label_name);
@@ -7625,6 +7627,20 @@ Label::get_addr(Translate_context* context, Location location)
7625
7627
return context->backend ()->label_address (label, location);
7626
7628
}
7627
7629
7630
+ // Return the dummy label that represents any instance of the blank label.
7631
+
7632
+ Label*
7633
+ Label::create_dummy_label ()
7634
+ {
7635
+ static Label* dummy_label;
7636
+ if (dummy_label == NULL )
7637
+ {
7638
+ dummy_label = new Label (" _" );
7639
+ dummy_label->set_is_used ();
7640
+ }
7641
+ return dummy_label;
7642
+ }
7643
+
7628
7644
// Class Unnamed_label.
7629
7645
7630
7646
// Get the backend representation for an unnamed label.
0 commit comments