Commit f4fca9d4 by Ian Lance Taylor

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
parent 47fa5d23
...@@ -5266,7 +5266,8 @@ Parse::range_clause_decl(const Typed_identifier_list* til, ...@@ -5266,7 +5266,8 @@ Parse::range_clause_decl(const Typed_identifier_list* til,
no->var_value()->set_type_from_range_value(); no->var_value()->set_type_from_range_value();
if (is_new) if (is_new)
any_new = true; 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) if (!any_new)
......
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