aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-06-24 17:57:13 -0400
committerJason Merrill <jason@gcc.gnu.org>2016-06-24 17:57:13 -0400
commita25bd9e6a2e5875b330e3303f392a2a7aa9b5251 (patch)
tree674e7e2461f1f0572e54a14ff71ae09257303531 /gcc/cp
parent53605f35cddd3c353ae9f7db1aaf9565a08826ea (diff)
downloadgcc-a25bd9e6a2e5875b330e3303f392a2a7aa9b5251.zip
gcc-a25bd9e6a2e5875b330e3303f392a2a7aa9b5251.tar.gz
gcc-a25bd9e6a2e5875b330e3303f392a2a7aa9b5251.tar.bz2
P0145R2: Refining Expression Order for C++ (complex LHS of =).
gcc/c-common/ * c-common.c (verify_tree) [COMPOUND_EXPR]: Fix handling on LHS of MODIFY_EXPR. gcc/cp/ * typeck.c (cp_build_modify_expr): Leave COMPOUND_EXPR on LHS. From-SVN: r237775
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/typeck.c26
2 files changed, 9 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a36cbff..33e10ba 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2016-06-24 Jason Merrill <jason@redhat.com>
+ P0145R2: Refining Expression Order for C++.
+ * typeck.c (cp_build_modify_expr): Leave COMPOUND_EXPR on LHS.
+
* tree.c (get_target_expr_sfinae): Handle bit-fields.
(build_target_expr): Call mark_rvalue_use.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 3704b88..fb6a16e 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7515,7 +7515,8 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
if (error_operand_p (lhs) || error_operand_p (rhs))
return error_mark_node;
- /* Handle control structure constructs used as "lvalues". */
+ /* Handle control structure constructs used as "lvalues". Note that we
+ leave COMPOUND_EXPR on the LHS because it is sequenced after the RHS. */
switch (TREE_CODE (lhs))
{
/* Handle --foo = 5; as these are valid constructs in C++. */
@@ -7525,31 +7526,16 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
lhs = build2 (TREE_CODE (lhs), TREE_TYPE (lhs),
cp_stabilize_reference (TREE_OPERAND (lhs, 0)),
TREE_OPERAND (lhs, 1));
- newrhs = cp_build_modify_expr (loc, TREE_OPERAND (lhs, 0),
- modifycode, rhs, complain);
- if (newrhs == error_mark_node)
- return error_mark_node;
- return build2 (COMPOUND_EXPR, lhstype, lhs, newrhs);
-
- /* Handle (a, b) used as an "lvalue". */
- case COMPOUND_EXPR:
- newrhs = cp_build_modify_expr (loc, TREE_OPERAND (lhs, 1),
- modifycode, rhs, complain);
- if (newrhs == error_mark_node)
- return error_mark_node;
- return build2 (COMPOUND_EXPR, lhstype,
- TREE_OPERAND (lhs, 0), newrhs);
+ lhs = build2 (COMPOUND_EXPR, lhstype, lhs, TREE_OPERAND (lhs, 0));
+ break;
case MODIFY_EXPR:
if (TREE_SIDE_EFFECTS (TREE_OPERAND (lhs, 0)))
lhs = build2 (TREE_CODE (lhs), TREE_TYPE (lhs),
cp_stabilize_reference (TREE_OPERAND (lhs, 0)),
TREE_OPERAND (lhs, 1));
- newrhs = cp_build_modify_expr (loc, TREE_OPERAND (lhs, 0), modifycode,
- rhs, complain);
- if (newrhs == error_mark_node)
- return error_mark_node;
- return build2 (COMPOUND_EXPR, lhstype, lhs, newrhs);
+ lhs = build2 (COMPOUND_EXPR, lhstype, lhs, TREE_OPERAND (lhs, 0));
+ break;
case MIN_EXPR:
case MAX_EXPR: