compiler: Treat map index expressions as lvalues in range expressions.
authorIan Lance Taylor <ian@gcc.gnu.org>
Sat, 31 Jan 2015 00:20:10 +0000 (00:20 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sat, 31 Jan 2015 00:20:10 +0000 (00:20 +0000)
Fixes golang/go#9695.

From-SVN: r220301

gcc/go/gofrontend/parse.cc

index 3e7c3728816ac607167f726ab982396c88e77878..29edba7650a2afd0626d673af657e6d032dd80b5 100644 (file)
@@ -4011,6 +4011,16 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit,
 
   token = this->advance_token();
 
+  if (lhs == NULL)
+    return;
+
+  // Map expressions act differently when they are lvalues.
+  for (Expression_list::iterator plv = lhs->begin();
+       plv != lhs->end();
+       ++plv)
+    if ((*plv)->index_expression() != NULL)
+      (*plv)->index_expression()->set_is_lvalue();
+
   if (p_range_clause != NULL && token->is_keyword(KEYWORD_RANGE))
     {
       if (op != OPERATOR_EQ)
@@ -4023,7 +4033,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit,
                                                may_be_composite_lit);
 
   // We've parsed everything; check for errors.
-  if (lhs == NULL || vals == NULL)
+  if (vals == NULL)
     return;
   for (Expression_list::const_iterator pe = lhs->begin();
        pe != lhs->end();
@@ -4042,13 +4052,6 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit,
        return;
     }
 
-  // Map expressions act differently when they are lvalues.
-  for (Expression_list::iterator plv = lhs->begin();
-       plv != lhs->end();
-       ++plv)
-    if ((*plv)->index_expression() != NULL)
-      (*plv)->index_expression()->set_is_lvalue();
-
   Call_expression* call;
   Index_expression* map_index;
   Receive_expression* receive;