aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-01-24 20:52:37 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-01-24 20:52:37 +0000
commit625d0ab2fd2894879590ccce150e71516c504288 (patch)
tree7878b9c212fd37ad5c2c2305ce698fd7abfa42dc /gcc/go/gofrontend
parent1efaf134d4d4037fd219f518aaeccab8591b1c02 (diff)
downloadgcc-625d0ab2fd2894879590ccce150e71516c504288.zip
gcc-625d0ab2fd2894879590ccce150e71516c504288.tar.gz
gcc-625d0ab2fd2894879590ccce150e71516c504288.tar.bz2
compiler: Simple statement in type switch is in different block.
From-SVN: r183496
Diffstat (limited to 'gcc/go/gofrontend')
-rw-r--r--gcc/go/gofrontend/parse.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 2d58185..06faeb6 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -4057,6 +4057,7 @@ Parse::switch_stat(Label* label)
Expression* switch_val = NULL;
bool saw_send_stmt;
Type_switch type_switch;
+ bool have_type_switch_block = false;
if (this->simple_stat_may_start_here())
{
switch_val = this->simple_stat(false, &saw_send_stmt, NULL,
@@ -4099,7 +4100,14 @@ Parse::switch_stat(Label* label)
id_loc));
if (is_coloneq)
{
- // This must be a TypeSwitchGuard.
+ // This must be a TypeSwitchGuard. It is in a
+ // different block from any initial SimpleStat.
+ if (saw_simple_stat)
+ {
+ this->gogo_->start_block(id_loc);
+ have_type_switch_block = true;
+ }
+
switch_val = this->simple_stat(false, &saw_send_stmt, NULL,
&type_switch);
if (!type_switch.found)
@@ -4142,13 +4150,23 @@ Parse::switch_stat(Label* label)
if (this->peek_token()->is_op(OPERATOR_SEMICOLON))
this->advance_token();
if (!this->peek_token()->is_op(OPERATOR_LCURLY))
- return;
+ {
+ if (have_type_switch_block)
+ this->gogo_->add_block(this->gogo_->finish_block(location),
+ location);
+ this->gogo_->add_block(this->gogo_->finish_block(location),
+ location);
+ return;
+ }
if (type_switch.found)
type_switch.expr = Expression::make_error(location);
}
else
{
error_at(this->location(), "expected %<{%>");
+ if (have_type_switch_block)
+ this->gogo_->add_block(this->gogo_->finish_block(this->location()),
+ location);
this->gogo_->add_block(this->gogo_->finish_block(this->location()),
location);
return;
@@ -4165,6 +4183,10 @@ Parse::switch_stat(Label* label)
if (statement != NULL)
this->gogo_->add_statement(statement);
+ if (have_type_switch_block)
+ this->gogo_->add_block(this->gogo_->finish_block(this->location()),
+ location);
+
this->gogo_->add_block(this->gogo_->finish_block(this->location()),
location);
}