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@googlegroups.com
Subject: Go patch committed: do not propagate address-taken of slice element to slice
Date: Fri, 22 Dec 2017 16:43:00 -0000	[thread overview]
Message-ID: <CAOyqgcXSNrU-Gd5YMEDew-jvBw-eBiSVhvDAs8Ytsbj=n=yH4g@mail.gmail.com> (raw)

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

This patch by Cherry Zhang fixes the Go frontend to not propagate
address-taken of a slice element to the slice.

Array_index_expression may be used for indexing/slicing array or
slice. If a slice element is address taken, the slice itself is not
necessarily address taken. Only propagate address-taken for arrays.

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

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

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 255976)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-83fc0e440b8c151edc5b1c67006257aad522ca04
+9b9bece388d1bacdc9d1d0024e722ffe449d221d
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc	(revision 255976)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -10871,6 +10871,14 @@ Array_index_expression::do_is_addressabl
   return this->array_->is_addressable();
 }
 
+void
+Array_index_expression::do_address_taken(bool escapes)
+{
+  // In &x[0], if x is a slice, then x's address is not taken.
+  if (!this->array_->type()->is_slice_type())
+    this->array_->address_taken(escapes);
+}
+
 // Get the backend representation for an array index.
 
 Bexpression*
Index: gcc/go/gofrontend/expressions.h
===================================================================
--- gcc/go/gofrontend/expressions.h	(revision 255976)
+++ gcc/go/gofrontend/expressions.h	(working copy)
@@ -2896,8 +2896,7 @@ class Array_index_expression : public Ex
   do_is_addressable() const;
 
   void
-  do_address_taken(bool escapes)
-  { this->array_->address_taken(escapes); }
+  do_address_taken(bool escapes);
 
   void
   do_issue_nil_check()

                 reply	other threads:[~2017-12-22 16:43 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='CAOyqgcXSNrU-Gd5YMEDew-jvBw-eBiSVhvDAs8Ytsbj=n=yH4g@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).