diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-31 16:47:17 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-31 16:47:17 +0000 |
commit | 9ebd2806f6e3c71a62d6df28b978d6fec53b50fb (patch) | |
tree | bf1ae6a71c0db2473fe2f0321f7e9335f328b216 /gcc/go | |
parent | 34ccb9c02a5456699ec6e04c51ab4cd1c1550e31 (diff) | |
download | gcc-9ebd2806f6e3c71a62d6df28b978d6fec53b50fb.zip gcc-9ebd2806f6e3c71a62d6df28b978d6fec53b50fb.tar.gz gcc-9ebd2806f6e3c71a62d6df28b978d6fec53b50fb.tar.bz2 |
Taking a slice of an array requires moving the array to the heap.
From-SVN: r171792
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 791ab07..e295c7d 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -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. |