Commit d8a99c7c by Ian Lance Taylor

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
parent 03625f07
...@@ -6878,7 +6878,11 @@ Builtin_call_expression::do_flatten(Gogo*, Named_object*, ...@@ -6878,7 +6878,11 @@ Builtin_call_expression::do_flatten(Gogo*, Named_object*,
++pa) ++pa)
{ {
if ((*pa)->is_nil_expression()) 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()) if (!(*pa)->is_variable())
{ {
Temporary_statement* temp = Temporary_statement* temp =
...@@ -14087,7 +14091,8 @@ class Slice_value_expression : public Expression ...@@ -14087,7 +14091,8 @@ class Slice_value_expression : public Expression
int int
Slice_value_expression::do_traverse(Traverse* traverse) 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->len_, traverse) == TRAVERSE_EXIT
|| Expression::traverse(&this->cap_, traverse) == TRAVERSE_EXIT) || Expression::traverse(&this->cap_, traverse) == TRAVERSE_EXIT)
return TRAVERSE_EXIT; return TRAVERSE_EXIT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment