aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 645eeb2..cf3aea7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6824,7 +6824,11 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup)
if (at_function_scope_p ())
{
add_decl_expr (var);
- *cleanup = cxx_maybe_build_cleanup (var);
+
+ if (TREE_STATIC (var))
+ init = add_stmt_to_compound (init, register_dtor_fn (var));
+ else
+ *cleanup = cxx_maybe_build_cleanup (var);
/* We must be careful to destroy the temporary only
after its initialization has taken place. If the