@@ -561,6 +561,17 @@ build_unary_op (tree_code code, tree type, tree arg)
561561 care about, storing the value in VALUEP. Callers must ensure that the
562562 returned expression is evaluated before VALUEP. */
563563
564+ tree
565+ stabilize_expr2 (tree exp)
566+ {
567+ if (!TREE_SIDE_EFFECTS (exp) || VOID_TYPE_P (TREE_TYPE (exp)))
568+ return exp;
569+
570+ tree init = force_target_expr (exp);
571+
572+ return compound_expr (init, TARGET_EXPR_SLOT (init));
573+ }
574+
564575tree
565576stabilize_expr (tree *valuep)
566577{
@@ -1193,6 +1204,7 @@ find_aggregate_field (tree type, tree ident, tree offset)
11931204
11941205 return NULL_TREE;
11951206}
1207+
11961208/* Return a constructor that matches the layout of the class expression EXP. */
11971209
11981210tree
@@ -1530,7 +1542,7 @@ indirect_ref (tree type, tree exp)
15301542 return exp;
15311543
15321544 /* Maybe rewrite: *(e1, e2) => (e1, *e2) */
1533- tree init = stabilize_expr (& exp);
1545+ exp = stabilize_expr2 ( exp);
15341546
15351547 if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE)
15361548 exp = fold_build1 (INDIRECT_REF, type, exp);
@@ -1540,7 +1552,7 @@ indirect_ref (tree type, tree exp)
15401552 exp = build_deref (exp);
15411553 }
15421554
1543- return compound_expr (init, exp) ;
1555+ return exp;
15441556}
15451557
15461558/* Returns indirect reference of EXP, which must be a pointer type. */
0 commit comments