if (TREE_CODE (t) == TARGET_EXPR
&& TARGET_EXPR_INITIAL (t) == r)
return t;
- else if (TREE_CODE (t) == CONSTRUCTOR)
- ;
+ else if (TREE_CODE (t) == CONSTRUCTOR || TREE_CODE (t) == CALL_EXPR)
+ /* Don't add a TARGET_EXPR if our argument didn't have one. */;
else if (TREE_CODE (t) == TARGET_EXPR && TARGET_EXPR_CLEANUP (t))
r = get_target_expr (r);
else
}
break;
- /* These are only for genericize time; they're here rather than in
- cp_genericize to avoid problems with the invisible reference
- transition. */
+ /* cp_genericize_{init,target}_expr are only for genericize time; they're
+ here rather than in cp_genericize to avoid problems with the invisible
+ reference transition. */
case INIT_EXPR:
if (data->genericize)
cp_genericize_init_expr (stmt_p);
case TARGET_EXPR:
if (data->genericize)
cp_genericize_target_expr (stmt_p);
+
+ /* Folding might replace e.g. a COND_EXPR with a TARGET_EXPR; in
+ that case, use it in place of this one. */
+ if (tree &init = TARGET_EXPR_INITIAL (stmt))
+ {
+ cp_walk_tree (&init, cp_fold_r, data, NULL);
+ *walk_subtrees = 0;
+ if (TREE_CODE (init) == TARGET_EXPR)
+ *stmt_p = init;
+ }
break;
default:
return false;
while (TREE_CODE (init) == COMPOUND_EXPR)
init = TREE_OPERAND (init, 1);
- return TREE_CODE (init) != AGGR_INIT_EXPR;
+ return (TREE_CODE (init) != AGGR_INIT_EXPR
+ && TREE_CODE (init) != VEC_INIT_EXPR);
}
/* True if EXPR expresses direct-initialization of a TYPE. */