Commit a25bd9e6 by Jason Merrill Committed by Jason Merrill

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
parent 53605f35
2016-06-24 Jason Merrill <jason@redhat.com>
P0145R2: Refining Expression Order for C++.
* c-common.c (verify_tree) [COMPOUND_EXPR]: Fix handling on LHS of
MODIFY_EXPR.
2016-06-24 Jakub Jelinek <jakub@redhat.com>
* c-common.c (check_builtin_function_arguments): Require last
......
......@@ -2980,13 +2980,15 @@ verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp,
case COMPOUND_EXPR:
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
tmp_before = tmp_nosp = tmp_list3 = 0;
tmp_before = tmp_nosp = tmp_list2 = tmp_list3 = 0;
verify_tree (TREE_OPERAND (x, 0), &tmp_before, &tmp_nosp, NULL_TREE);
warn_for_collisions (tmp_nosp);
merge_tlist (pbefore_sp, tmp_before, 0);
merge_tlist (pbefore_sp, tmp_nosp, 0);
verify_tree (TREE_OPERAND (x, 1), &tmp_list3, pno_sp, NULL_TREE);
verify_tree (TREE_OPERAND (x, 1), &tmp_list3, &tmp_list2, NULL_TREE);
warn_for_collisions (tmp_list2);
merge_tlist (pbefore_sp, tmp_list3, 0);
merge_tlist (pno_sp, tmp_list2, 0);
return;
case COND_EXPR:
......
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.
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment