Skip to content

Commit

Permalink
compiler: Allow multiple blank label definitions.
Browse files Browse the repository at this point in the history
    
    Fixes golang/go#12316.
    
    Reviewed-on: https://go-review.googlesource.com/13907


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227284 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ian committed Aug 27, 2015
1 parent bfb381a commit 1b8b2b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcc/go/gofrontend/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a1d2cac484f46068b5a6ddf3e041d425a3d25e0c
9ae5835a010a55fba875103be5f4e61485a97099

The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
7 changes: 7 additions & 0 deletions gcc/go/gofrontend/gogo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,8 @@ class Label
void
define(Location location, Bindings_snapshot* snapshot)
{
if (this->is_dummy_label())
return;
go_assert(Linemap::is_unknown_location(this->location_)
&& this->snapshot_ == NULL);
this->location_ = location;
Expand All @@ -2709,6 +2711,11 @@ class Label
static Label*
create_dummy_label();

// Return TRUE if this is a dummy label.
bool
is_dummy_label() const
{ return this->name_ == "_"; }

private:
// The name of the label.
std::string name_;
Expand Down
5 changes: 5 additions & 0 deletions gcc/go/gofrontend/statements.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3080,6 +3080,11 @@ Label_statement::do_traverse(Traverse*)
Bstatement*
Label_statement::do_get_backend(Translate_context* context)
{
if (this->label_->is_dummy_label())
{
Bexpression* bce = context->backend()->boolean_constant_expression(false);
return context->backend()->expression_statement(bce);
}
Blabel* blabel = this->label_->get_backend_label(context);
return context->backend()->label_definition_statement(blabel);
}
Expand Down

0 comments on commit 1b8b2b2

Please sign in to comment.