@@ -524,14 +524,30 @@ d_save_expr (tree exp)
524
524
static tree
525
525
build_unary_op (tree_code code, tree type, tree arg)
526
526
{
527
- /* Given ((e1, ...), eN):
528
- Treat the last RHS 'eN' expression as the lvalue part. */
527
+ /* Given ((e1, ...), eN), treat the last RHS 'eN' expression as the
528
+ lvalue part. */
529
529
if (TREE_CODE (arg) == COMPOUND_EXPR)
530
530
{
531
531
tree result = build_unary_op (code, type, TREE_OPERAND (arg, 1 ));
532
532
return compound_expr (TREE_OPERAND (arg, 0 ), result);
533
533
}
534
534
535
+ /* Given (e1 = e2), (++e1), or (--e1), convert 'e1' into an lvalue. */
536
+ if (TREE_CODE (arg) == MODIFY_EXPR
537
+ || TREE_CODE (arg) == PREINCREMENT_EXPR
538
+ || TREE_CODE (arg) == PREDECREMENT_EXPR)
539
+ {
540
+ if (TREE_SIDE_EFFECTS (TREE_OPERAND (arg, 0 )))
541
+ {
542
+ arg = build2 (TREE_CODE (arg), TREE_TYPE (arg),
543
+ stabilize_reference (TREE_OPERAND (arg, 0 )),
544
+ TREE_OPERAND (arg, 1 ));
545
+ gcc_unreachable ();
546
+ }
547
+ return build_unary_op (code, type,
548
+ compound_expr (arg, TREE_OPERAND (arg, 0 )));
549
+ }
550
+
535
551
if (code == ADDR_EXPR)
536
552
{
537
553
/* Can't take the address of a manifest constant, get the real value of
@@ -567,7 +583,8 @@ stabilize_expr2 (tree *valuep)
567
583
tree expr = *valuep;
568
584
569
585
/* No side effects or expression has no value. */
570
- if (!TREE_SIDE_EFFECTS (expr) || VOID_TYPE_P (TREE_TYPE (expr)))
586
+ if (!TREE_SIDE_EFFECTS (expr) || TREE_CODE (expr) == SAVE_EXPR
587
+ || VOID_TYPE_P (TREE_TYPE (expr)))
571
588
return NULL_TREE;
572
589
573
590
tree init = force_target_expr (expr);
@@ -1322,9 +1339,6 @@ component_ref (tree object, tree field)
1322
1339
1323
1340
gcc_assert (TREE_CODE (field) == FIELD_DECL);
1324
1341
1325
- /* Maybe rewrite: (e1, e2).field => (e1, e2.field) */
1326
- tree init = stabilize_expr (&object);
1327
-
1328
1342
/* If the FIELD is from an anonymous aggregate, generate a reference
1329
1343
to the anonymous data member, and recur to find FIELD. */
1330
1344
if (ANON_AGGR_TYPE_P (DECL_CONTEXT (field)))
@@ -1334,10 +1348,8 @@ component_ref (tree object, tree field)
1334
1348
object = component_ref (object, anonymous_field);
1335
1349
}
1336
1350
1337
- tree result = fold_build3_loc (input_location, COMPONENT_REF,
1338
- TREE_TYPE (field), object, field, NULL_TREE);
1339
-
1340
- return compound_expr (init, result);
1351
+ return fold_build3_loc (input_location, COMPONENT_REF, TREE_TYPE (field),
1352
+ object, field, NULL_TREE);
1341
1353
}
1342
1354
1343
1355
/* Build an assignment expression of lvalue LHS from value RHS.
0 commit comments