public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@golang.org>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
		gofrontend-dev <gofrontend-dev@googlegroups.com>
Subject: Go patch committed: Use correct value in 2-case select send
Date: Tue, 23 Jul 2019 18:28:00 -0000	[thread overview]
Message-ID: <CAOyqgcUMqD1UbWV1bex0EK1YzHOtBE15Qj2UJ30eTL_B-Jt_qA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]

This Go frontend patch by Cherry Zhang fixes the 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 patch ensures that
we use the correct value type for the send.  This fixes
https://golang.org/issue/33235.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1687 bytes --]

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 273713)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -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.
Index: gcc/go/gofrontend/statements.cc
===================================================================
--- gcc/go/gofrontend/statements.cc	(revision 273577)
+++ gcc/go/gofrontend/statements.cc	(working copy)
@@ -5880,6 +5880,7 @@ Select_statement::lower_two_case(Block*
      : 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*
     {
       // 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*
     }
   else
     {
-      Type* valtype = chan->type()->channel_type()->element_type();
       Temporary_statement* ts = Statement::make_temporary(valtype, NULL, loc);
       b->add_statement(ts);
 

                 reply	other threads:[~2019-07-23 17:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOyqgcUMqD1UbWV1bex0EK1YzHOtBE15Qj2UJ30eTL_B-Jt_qA@mail.gmail.com \
    --to=iant@golang.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gofrontend-dev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).