summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-20 17:25:24 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-20 17:25:24 +0000
commit7da522b3c34abcc4e4b31cb6fbec3778c0d39a3f (patch)
treef61bfa24d2e41f00fe94d06ba1dc5377170b7d29
parentb4a3304904dbbef78811739b1a35ed4db06a6d3d (diff)
downloadgcc-7da522b3c34abcc4e4b31cb6fbec3778c0d39a3f.tar.gz
compiler: Create dummy labels for blank labels.
Fixes golang/go#11591. Reviewed-on: https://go-review.googlesource.com/12043 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226009 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/gogo.cc26
-rw-r--r--gcc/go/gofrontend/gogo.h4
3 files changed, 26 insertions, 6 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 1b1e3cdc045..463b2036f11 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-19ff97ed3eb07d902bc4b3f97b21c4b6df834ad2
+5c49a77455f52ba2c7eddb5b831456dc1c67b02f
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index ad4672ffe05..d521fb1e2b7 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -1937,10 +1937,6 @@ Label*
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);
@@ -4724,7 +4720,13 @@ Function::add_label_definition(Gogo* gogo, const std::string& label_name,
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);
@@ -7625,6 +7627,20 @@ Label::get_addr(Translate_context* context, Location location)
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.
diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h
index ffc2440f8ff..51f628fa3b2 100644
--- a/gcc/go/gofrontend/gogo.h
+++ b/gcc/go/gofrontend/gogo.h
@@ -2688,6 +2688,10 @@ class 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_;