compiler: Don't generate value reference in range clause if receiver is a sink.
authorIan Lance Taylor <ian@gcc.gnu.org>
Sat, 17 Aug 2013 18:04:35 +0000 (18:04 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sat, 17 Aug 2013 18:04:35 +0000 (18:04 +0000)
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

gcc/go/gofrontend/parse.cc

index 429d91bafe2bdc986421b3896e94bddb0394d688..9d112850fee27151f88bc93e956f603892db4f69 100644 (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)