summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-05-11 00:05:08 (GMT)
committerIan Lance Taylor <iant@golang.org>2022-05-17 22:48:43 (GMT)
commit1bfb823e2a7346ef55bd53a5354770599f7a550b (patch)
tree2bbeb7a6a0927e1fc0f5a7d62d94091f03426f02
parent2b0c8377729a3c62a05897136666574ab939aaab (diff)
downloadgcc-1bfb823e2a7346ef55bd53a5354770599f7a550b.zip
gcc-1bfb823e2a7346ef55bd53a5354770599f7a550b.tar.gz
gcc-1bfb823e2a7346ef55bd53a5354770599f7a550b.tar.bz2
compiler: load LHS subexpressions of op= assignment only once
Fixes golang/go#52811 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405617
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/statements.cc10
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index daa725f..5fa8bec 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-f5bc28a30b7503015bbef38afb5812313184e822
+9d07072e58ca4f9f05343dfd3475b9f49dae5ec5
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 95fa3c4..b3db843 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -1260,6 +1260,16 @@ Assignment_operation_statement::do_lower(Gogo*, Named_object*,
Move_ordered_evals moe(b);
this->lhs_->traverse_subexpressions(&moe);
+ // We can still be left with subexpressions that have to be loaded
+ // even if they don't have side effects themselves, in case the RHS
+ // changes variables named on the LHS.
+ int i;
+ if (this->lhs_->must_eval_subexpressions_in_order(&i))
+ {
+ Move_subexpressions ms(i, b);
+ this->lhs_->traverse_subexpressions(&ms);
+ }
+
Expression* lval = this->lhs_->copy();
Operator op;