aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-02-01 14:29:28 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-02-01 14:29:28 +0000
commitf4f3b9d396227387fbf6ad25e49dd886aa13321f (patch)
tree12f2097fd1db27f5eb51d087f9e43c82120bf5cb /gcc/go/gofrontend
parentc2453253e725d72661385827a0d1e67b31f31c6a (diff)
downloadgcc-f4f3b9d396227387fbf6ad25e49dd886aa13321f.zip
gcc-f4f3b9d396227387fbf6ad25e49dd886aa13321f.tar.gz
gcc-f4f3b9d396227387fbf6ad25e49dd886aa13321f.tar.bz2
compiler: Permit a general expression in case x := <-c.
From-SVN: r183802
Diffstat (limited to 'gcc/go/gofrontend')
-rw-r--r--gcc/go/gofrontend/parse.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 06faeb6..1359f4c 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -4640,9 +4640,14 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val,
if (token->is_op(OPERATOR_COLONEQ))
{
// case rv := <-c:
- if (!this->advance_token()->is_op(OPERATOR_CHANOP))
+ this->advance_token();
+ Expression* e = this->expression(PRECEDENCE_NORMAL, false, false,
+ NULL);
+ Receive_expression* re = e->receive_expression();
+ if (re == NULL)
{
- error_at(this->location(), "expected %<<-%>");
+ if (!e->is_error_expression())
+ error_at(this->location(), "expected receive expression");
return false;
}
if (recv_var == "_")
@@ -4653,8 +4658,7 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val,
}
*is_send = false;
*varname = gogo->pack_hidden_name(recv_var, is_rv_exported);
- this->advance_token();
- *channel = this->expression(PRECEDENCE_NORMAL, false, true, NULL);
+ *channel = re->channel();
return true;
}
else if (token->is_op(OPERATOR_COMMA))
@@ -4671,9 +4675,15 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val,
if (token->is_op(OPERATOR_COLONEQ))
{
// case rv, rc := <-c:
- if (!this->advance_token()->is_op(OPERATOR_CHANOP))
+ this->advance_token();
+ Expression* e = this->expression(PRECEDENCE_NORMAL, false,
+ false, NULL);
+ Receive_expression* re = e->receive_expression();
+ if (re == NULL)
{
- error_at(this->location(), "expected %<<-%>");
+ if (!e->is_error_expression())
+ error_at(this->location(),
+ "expected receive expression");
return false;
}
if (recv_var == "_" && recv_closed == "_")
@@ -4689,9 +4699,7 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val,
if (recv_closed != "_")
*closedname = gogo->pack_hidden_name(recv_closed,
is_rc_exported);
- this->advance_token();
- *channel = this->expression(PRECEDENCE_NORMAL, false, true,
- NULL);
+ *channel = re->channel();
return true;
}