aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-07-08 23:33:54 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-07-08 23:33:54 -0400
commit4063e61bc63c3803f8ab2d625ebe8432ac06b3da (patch)
tree2933e4a1c40cd6d7cb203f1eec34d632fcacf4b8 /gcc/c-family
parent2fda8e144a7db5ba6025cfe643da0c6111cc2b0f (diff)
downloadgcc-4063e61bc63c3803f8ab2d625ebe8432ac06b3da.zip
gcc-4063e61bc63c3803f8ab2d625ebe8432ac06b3da.tar.gz
gcc-4063e61bc63c3803f8ab2d625ebe8432ac06b3da.tar.bz2
re PR c++/45437 (Loses reference during update)
PR c++/45437 gcc/ * gimplify.c (goa_stabilize_expr): Handle RHS preevaluation in compound assignment. gcc/c-family/ * c-omp.c (check_omp_for_incr_expr): Handle preevaluation. gcc/cp/ * typeck.c (cp_build_modify_expr): Preevaluate RHS. From-SVN: r176072
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog3
-rw-r--r--gcc/c-family/c-omp.c21
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 72a118a..87930c2 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,5 +1,8 @@
2011-07-08 Jason Merrill <jason@redhat.com>
+ PR c++/45437
+ * c-omp.c (check_omp_for_incr_expr): Handle preevaluation.
+
PR c++/49673
* c-common.c (c_apply_type_quals_to_decl): Don't check
TYPE_NEEDS_CONSTRUCTING.
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 1ee0bf0..d2256ff 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -213,6 +213,27 @@ check_omp_for_incr_expr (location_t loc, tree exp, tree decl)
return fold_build2_loc (loc, PLUS_EXPR,
TREE_TYPE (exp), TREE_OPERAND (exp, 0), t);
break;
+ case COMPOUND_EXPR:
+ {
+ /* cp_build_modify_expr forces preevaluation of the RHS to make
+ sure that it is evaluated before the lvalue-rvalue conversion
+ is applied to the LHS. Reconstruct the original expression. */
+ tree op0 = TREE_OPERAND (exp, 0);
+ if (TREE_CODE (op0) == TARGET_EXPR
+ && !VOID_TYPE_P (TREE_TYPE (op0)))
+ {
+ tree op1 = TREE_OPERAND (exp, 1);
+ tree temp = TARGET_EXPR_SLOT (op0);
+ if (TREE_CODE_CLASS (TREE_CODE (op1)) == tcc_binary
+ && TREE_OPERAND (op1, 1) == temp)
+ {
+ op1 = copy_node (op1);
+ TREE_OPERAND (op1, 1) = TARGET_EXPR_INITIAL (op0);
+ return check_omp_for_incr_expr (loc, op1, decl);
+ }
+ }
+ break;
+ }
default:
break;
}