diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-26 05:32:46 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-26 05:32:46 +0000 |
commit | e2e5c70f5c999df78a5d1edd8b87651d08d72400 (patch) | |
tree | 01f8f324f7a665ba41e5e94ebd4743769f965567 /gcc/go/gofrontend/parse.cc | |
parent | 8ac5e12e5f69ba3a8559e6b5836d6d18b8ac7ff3 (diff) | |
download | gcc-e2e5c70f5c999df78a5d1edd8b87651d08d72400.zip gcc-e2e5c70f5c999df78a5d1edd8b87651d08d72400.tar.gz gcc-e2e5c70f5c999df78a5d1edd8b87651d08d72400.tar.bz2 |
Correctly parse select case <-c <- v.
From-SVN: r171540
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index cdee68a..18310cc 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -4375,16 +4375,24 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val, // send or receive expression. If SAW_COMMA is true, then *VAL is // set and we just read a comma. - if (!saw_comma && this->peek_token()->is_op(OPERATOR_CHANOP)) + Expression* e; + if (saw_comma || !this->peek_token()->is_op(OPERATOR_CHANOP)) + e = this->expression(PRECEDENCE_NORMAL, true, true, NULL); + else { // case <-c: *is_send = false; this->advance_token(); *channel = this->expression(PRECEDENCE_NORMAL, false, true, NULL); - return true; - } - Expression* e = this->expression(PRECEDENCE_NORMAL, true, true, NULL); + // The next token should be ':'. If it is '<-', then we have + // case <-c <- v: + // which is to say, send on a channel received from a channel. + if (!this->peek_token()->is_op(OPERATOR_CHANOP)) + return true; + + e = Expression::make_receive(*channel, (*channel)->location()); + } if (this->peek_token()->is_op(OPERATOR_EQ)) { |