aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2017-02-22 20:15:43 -0500
committerJason Merrill <jason@gcc.gnu.org>2017-02-22 20:15:43 -0500
commit680ed1065a3701a55f1a800db4d70f08e5ea5194 (patch)
treeda21f37a3a8e98b2bf848732e7cfe510014d3aad /gcc
parenta4759f362f5b1eeeea81beb17eedef6881096cc6 (diff)
downloadgcc-680ed1065a3701a55f1a800db4d70f08e5ea5194.zip
gcc-680ed1065a3701a55f1a800db4d70f08e5ea5194.tar.gz
gcc-680ed1065a3701a55f1a800db4d70f08e5ea5194.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/call.c11
-rw-r--r--gcc/testsuite/g++.dg/init/cleanup4.C22
3 files changed, 32 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9d6a9a6..fb17a19 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2017-02-22 Jason Merrill <jason@redhat.com>
+ 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 <jakub@redhat.com>
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 93fae0d..f7924f0 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 0000000..b9769e3
--- /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();
+}