-19ff97ed3eb07d902bc4b3f97b21c4b6df834ad2
+5c49a77455f52ba2c7eddb5b831456dc1c67b02f
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Gogo::add_label_definition(const std::string& label_name,
Location location)
{
- // A label with a blank identifier is never declared or defined.
- if (label_name == "_")
- return NULL;
-
go_assert(!this->functions_.empty());
Function* func = this->functions_.back().function->func_value();
Label* label = func->add_label_definition(this, label_name, location);
std::pair<Labels::iterator, bool> ins =
this->labels_.insert(std::make_pair(label_name, lnull));
Label* label;
- if (ins.second)
+ if (label_name == "_")
+ {
+ label = Label::create_dummy_label();
+ if (ins.second)
+ ins.first->second = label;
+ }
+ else if (ins.second)
{
// This is a new label.
label = new Label(label_name);
return context->backend()->label_address(label, location);
}
+// Return the dummy label that represents any instance of the blank label.
+
+Label*
+Label::create_dummy_label()
+{
+ static Label* dummy_label;
+ if (dummy_label == NULL)
+ {
+ dummy_label = new Label("_");
+ dummy_label->set_is_used();
+ }
+ return dummy_label;
+}
+
// Class Unnamed_label.
// Get the backend representation for an unnamed label.
Bexpression*
get_addr(Translate_context*, Location location);
+ // Return a dummy label, representing any instance of the blank label.
+ static Label*
+ create_dummy_label();
+
private:
// The name of the label.
std::string name_;