diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-12-17 01:04:39 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-12-17 01:04:39 +0000 |
commit | d8a99c7c6bce947706eeafbf69ec214845eb4a66 (patch) | |
tree | 5a271d4630e9f505f2b3001cb9d31874df347a89 /gcc/go | |
parent | 03625f0717107775ae01d7bd5a82bc081c96c13c (diff) | |
download | gcc-d8a99c7c6bce947706eeafbf69ec214845eb4a66.zip gcc-d8a99c7c6bce947706eeafbf69ec214845eb4a66.tar.gz gcc-d8a99c7c6bce947706eeafbf69ec214845eb4a66.tar.bz2 |
compiler: Don't crash on append with single argument.
Instead of allocating an empty slice literal, use a slice
value with a nil pointer.
From-SVN: r218806
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 9f68f77..83ee6d9 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -6878,7 +6878,11 @@ Builtin_call_expression::do_flatten(Gogo*, Named_object*, ++pa) { if ((*pa)->is_nil_expression()) - *pa = Expression::make_slice_composite_literal(at, NULL, loc); + { + Expression* nil = Expression::make_nil(loc); + Expression* zero = Expression::make_integer_ul(0, NULL, loc); + *pa = Expression::make_slice_value(at, nil, zero, zero, loc); + } if (!(*pa)->is_variable()) { Temporary_statement* temp = @@ -14087,7 +14091,8 @@ class Slice_value_expression : public Expression int Slice_value_expression::do_traverse(Traverse* traverse) { - if (Expression::traverse(&this->valptr_, traverse) == TRAVERSE_EXIT + if (Type::traverse(this->type_, traverse) == TRAVERSE_EXIT + || Expression::traverse(&this->valptr_, traverse) == TRAVERSE_EXIT || Expression::traverse(&this->len_, traverse) == TRAVERSE_EXIT || Expression::traverse(&this->cap_, traverse) == TRAVERSE_EXIT) return TRAVERSE_EXIT; |