OSDN Git Service

Taking a slice of an array requires moving the array to the heap.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Mar 2011 16:47:17 +0000 (16:47 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Mar 2011 16:47:17 +0000 (16:47 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171792 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc

index 791ab07..e295c7d 100644 (file)
@@ -9283,10 +9283,13 @@ Array_index_expression::do_check_types(Gogo*)
 
   // A slice of an array requires an addressable array.  A slice of a
   // slice is always possible.
-  if (this->end_ != NULL
-      && !array_type->is_open_array_type()
-      && !this->array_->is_addressable())
-    this->report_error(_("array is not addressable"));
+  if (this->end_ != NULL && !array_type->is_open_array_type())
+    {
+      if (!this->array_->is_addressable())
+       this->report_error(_("array is not addressable"));
+      else
+       this->array_->address_taken(true);
+    }
 }
 
 // Return whether this expression is addressable.