compiler: do not propagate address-taken of a slice element to the slice
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 22 Dec 2017 16:43:28 +0000 (16:43 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 22 Dec 2017 16:43:28 +0000 (16:43 +0000)
    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.

    Reviewed-on: https://go-review.googlesource.com/83877

From-SVN: r255977

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/expressions.h

index b81922efe5941ca9069a7af19961d68ecb694a54..3ba3462647818b7986dd2593fe4acdecd030daff 100644 (file)
@@ -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 8ae1013a6a9d5dcfbbef4c554adf3b19342ebed1..f5adc18586db303400b5af1fc45998ea88e03dc3 100644 (file)
@@ -10871,6 +10871,14 @@ Array_index_expression::do_is_addressable() const
   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 a4f655828a53c54b7650e36894fe2c340fddaf5e..cb6089005660b7a8ebedb34badd711d9b7c8a69b 100644 (file)
@@ -2896,8 +2896,7 @@ class Array_index_expression : public Expression
   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()