diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-07-11 14:22:12 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-07-11 14:22:12 +0000 |
commit | 305130b92e1a785d89178ce6334ead38e975268f (patch) | |
tree | bda3b9e97b0fab2129706a037775832f83e6982f /gcc/go/gofrontend/expressions.h | |
parent | 2bae8b2fadab13b6f886829f782e4d5cffdfafd6 (diff) | |
download | gcc-305130b92e1a785d89178ce6334ead38e975268f.zip gcc-305130b92e1a785d89178ce6334ead38e975268f.tar.gz gcc-305130b92e1a785d89178ce6334ead38e975268f.tar.bz2 |
compiler: fix evaluation order of LHS index expressions
The spec says that when an index expression appears on the left hand
side of an assignment, the operands should be evaluated. The
gofrontend code was assuming that that only referred to the index
operand. But discussion of https://golang.org/issue/23188 has
clarified that this means both the slice/map/string operand and the
index operand. Adjust the gofrontend code accordingly.
Fixes golang/go#23188
Reviewed-on: https://go-review.googlesource.com/123155
From-SVN: r262554
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r-- | gcc/go/gofrontend/expressions.h | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index a58c79c..5fa4171 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -2771,12 +2771,10 @@ class Index_expression : public Parser_expression this->location()); } + // This shouldn't be called--we don't know yet. bool - do_must_eval_subexpressions_in_order(int* skip) const - { - *skip = 1; - return true; - } + do_must_eval_subexpressions_in_order(int*) const + { go_unreachable(); } void do_dump_expression(Ast_dump_context*) const; @@ -2882,11 +2880,7 @@ class Array_index_expression : public Expression } bool - do_must_eval_subexpressions_in_order(int* skip) const - { - *skip = 1; - return true; - } + do_must_eval_subexpressions_in_order(int* skip) const; bool do_is_addressable() const; @@ -2965,11 +2959,8 @@ class String_index_expression : public Expression } bool - do_must_eval_subexpressions_in_order(int* skip) const - { - *skip = 1; - return true; - } + do_must_eval_subexpressions_in_order(int*) const + { return true; } Bexpression* do_get_backend(Translate_context*); @@ -3052,11 +3043,8 @@ class Map_index_expression : public Expression } bool - do_must_eval_subexpressions_in_order(int* skip) const - { - *skip = 1; - return true; - } + do_must_eval_subexpressions_in_order(int*) const + { return true; } // A map index expression is an lvalue but it is not addressable. |