@@ -517,6 +517,24 @@ d_save_expr (tree exp)
517
517
return exp ;
518
518
}
519
519
520
+ /* Build an unary op CODE to the expression ARG. If the expression can be
521
+ broken down so that the operation is applied only to the part whose value we
522
+ care about, then handle lowering to keep lvalues trivial. */
523
+
524
+ static tree
525
+ build_unary_op (tree_code code, tree type, tree arg)
526
+ {
527
+ /* Given ((e1, ...), eN):
528
+ Handle the last RHS 'eN' expression as an lvalue. */
529
+ if (TREE_CODE (arg) == COMPOUND_EXPR)
530
+ {
531
+ tree result = build_unary_op (code, type, TREE_OPERAND (arg, 1 ));
532
+ return compound_expr (TREE_OPERAND (arg, 0 ), result);
533
+ }
534
+
535
+ return fold_build1_loc (input_location, code, type, arg);
536
+ }
537
+
520
538
/* VALUEP is an expression we want to pre-evaluate or perform a computation on.
521
539
The expression returned by this function is the part whose value we don't
522
540
care about, storing the value in VALUEP. Callers must ensure that the
@@ -1360,11 +1378,7 @@ build_nop (tree type, tree exp)
1360
1378
if (error_operand_p (exp ))
1361
1379
return exp ;
1362
1380
1363
- /* Maybe rewrite: cast(TYPE)(e1, e2) => (e1, cast(TYPE) e2) */
1364
- tree init = stabilize_expr (&exp );
1365
- exp = fold_build1_loc (input_location, NOP_EXPR, type, exp );
1366
-
1367
- return compound_expr (init, exp );
1381
+ return build_unary_op (NOP_EXPR, type, exp );
1368
1382
}
1369
1383
1370
1384
/* Return EXP to be viewed as being another type TYPE. Same as build_nop,
0 commit comments