diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-31 00:20:10 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-31 00:20:10 +0000 |
commit | 62b8d3df506722f004baa15f57e1d6d64f3771bb (patch) | |
tree | 0ad264db38d1315f3f7ab7a22dd919f00be68edd /gcc/go | |
parent | 9b9b40bc37e72eb47db2bbe5c5fc59596d5e1cef (diff) | |
download | gcc-62b8d3df506722f004baa15f57e1d6d64f3771bb.tar.gz |
compiler: Treat map index expressions as lvalues in range expressions.
Fixes golang/go#9695.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220301 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 19 |
1 files changed, 11 insertions, 8 deletions
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; |