aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r--gcc/cp/tree.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 25927ae..6fbc99e 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -404,9 +404,15 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain)
|| useless_type_conversion_p (TREE_TYPE (decl),
TREE_TYPE (value)));
- t = cxx_maybe_build_cleanup (decl, complain);
- if (t == error_mark_node)
- return error_mark_node;
+ if (complain & tf_no_cleanup)
+ /* The caller is building a new-expr and does not need a cleanup. */
+ t = NULL_TREE;
+ else
+ {
+ t = cxx_maybe_build_cleanup (decl, complain);
+ if (t == error_mark_node)
+ return error_mark_node;
+ }
t = build4 (TARGET_EXPR, type, decl, value, t, NULL_TREE);
if (EXPR_HAS_LOCATION (value))
SET_EXPR_LOCATION (t, EXPR_LOCATION (value));