From 680ed1065a3701a55f1a800db4d70f08e5ea5194 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 22 Feb 2017 20:15:43 -0500 Subject: [PATCH] PR c++/79679 - missing destructor for argument PR c++/79679 - missing destructor for argument * call.c (build_over_call): Don't pass tf_no_cleanup to argument conversions. From-SVN: r245672 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/call.c | 11 ++++++----- gcc/testsuite/g++.dg/init/cleanup4.C | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/init/cleanup4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9d6a9a67c42..fb17a1913d2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-02-22 Jason Merrill + PR c++/79679 - missing destructor for argument + * call.c (build_over_call): Don't pass tf_no_cleanup to argument + conversions. + * pt.c (do_class_deduction): Handle 0 argument case. 2017-02-22 Jakub Jelinek diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 93fae0d15b6..f7924f0f4cd 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7838,12 +7838,13 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) if (flags & LOOKUP_NO_CONVERSION) conv->user_conv_p = true; - val = convert_like_with_context (conv, arg, fn, i - is_method, - conversion_warning - ? complain - : complain & (~tf_warning)); + tsubst_flags_t arg_complain = complain & (~tf_no_cleanup); + if (!conversion_warning) + arg_complain &= ~tf_warning; - val = convert_for_arg_passing (type, val, complain); + val = convert_like_with_context (conv, arg, fn, i - is_method, + arg_complain); + val = convert_for_arg_passing (type, val, arg_complain); if (val == error_mark_node) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/init/cleanup4.C b/gcc/testsuite/g++.dg/init/cleanup4.C new file mode 100644 index 00000000000..b9769e3bbeb --- /dev/null +++ b/gcc/testsuite/g++.dg/init/cleanup4.C @@ -0,0 +1,22 @@ +// PR c++/79679 +// { dg-do run } + +int count; +struct S { + S() { ++count; } + S(const S&) { ++count; } + ~S() { --count; } +}; + +struct T { + T(S) {} +}; + +int main() { + { + S s; + T u(s); + } + if (count) + __builtin_abort(); +} -- 2.30.2