compiler: Don't generate value reference in range clause if receiver is a sink.

The panic in test/fixedbugs/bug454.go was caused by the generation of an unnecessary var reference when writing a range value into a sink. If the receiving variable is a sink, there's no need to dereference a possible NULL pointer.

Fixes Issue 24.

From-SVN: r201815
This commit is contained in:
Ian Lance Taylor 2013-08-17 18:04:35 +00:00
parent 47fa5d2302
commit f4fca9d481

View File

@ -5266,7 +5266,8 @@ Parse::range_clause_decl(const Typed_identifier_list* til,
no->var_value()->set_type_from_range_value();
if (is_new)
any_new = true;
p_range_clause->value = Expression::make_var_reference(no, location);
if (!Gogo::is_sink_name(pti->name()))
p_range_clause->value = Expression::make_var_reference(no, location);
}
if (!any_new)