aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-07-23 17:20:36 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-07-23 17:20:36 +0000
commit40768ee0bc9965d109692f884f8588626e01e3fe (patch)
tree0ca33f701cbac984f561bacd9fef3701d8c76eda /gcc
parent9bf40084738e155bf69ab7215a69f74d589931d1 (diff)
downloadgcc-40768ee0bc9965d109692f884f8588626e01e3fe.zip
gcc-40768ee0bc9965d109692f884f8588626e01e3fe.tar.gz
gcc-40768ee0bc9965d109692f884f8588626e01e3fe.tar.bz2
compiler: use correct value type in 2-case select send
In the channel-send case, the value to be sent may needs an (implicit) type conversion to the channel element type. This CL ensures that we use the correct value type for the send. Fixes golang/go#33235. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/187177 From-SVN: r273743
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/statements.cc5
2 files changed, 4 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index dabd5a3..ba7282e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-b7bce0dbccb978d33eb8ce0bffc02fae2c2857c1
+480477ca64c3001b9c7e92ef8b978dc92a5912d2
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/statements.cc b/gcc/go/gofrontend/statements.cc
index 27c4b95..6d9c0eb 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -5880,6 +5880,7 @@ Select_statement::lower_two_case(Block* b)
: this->clauses_->at(1));
Location loc = this->location();
Expression* chan = chancase.channel();
+ Type* valtype = chan->type()->channel_type()->element_type();
Temporary_statement* chantmp = Statement::make_temporary(NULL, chan, loc);
b->add_statement(chantmp);
@@ -5891,7 +5892,8 @@ Select_statement::lower_two_case(Block* b)
{
// if selectnbsend(chan, &val) { body } else { default body }
- Temporary_statement* ts = Statement::make_temporary(NULL, chancase.val(), loc);
+ Temporary_statement* ts =
+ Statement::make_temporary(valtype, chancase.val(), loc);
// Tell the escape analysis that the value escapes, as it may be sent
// to a channel.
ts->set_value_escapes();
@@ -5904,7 +5906,6 @@ Select_statement::lower_two_case(Block* b)
}
else
{
- Type* valtype = chan->type()->channel_type()->element_type();
Temporary_statement* ts = Statement::make_temporary(valtype, NULL, loc);
b->add_statement(ts);