From: Ian Lance Taylor Date: Sat, 31 Jan 2015 00:20:10 +0000 (+0000) Subject: compiler: Treat map index expressions as lvalues in range expressions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=106aaf4f821d2a574c2e877740e513fb2eda4869;p=gcc.git compiler: Treat map index expressions as lvalues in range expressions. Fixes golang/go#9695. From-SVN: r220301 --- diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 3e7c3728816..29edba7650a 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -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;