PR c++/79679 - missing destructor for argument
authorJason Merrill <jason@redhat.com>
Thu, 23 Feb 2017 01:15:43 +0000 (20:15 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Feb 2017 01:15:43 +0000 (20:15 -0500)
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
gcc/cp/call.c
gcc/testsuite/g++.dg/init/cleanup4.C [new file with mode: 0644]

index 9d6a9a6..fb17a19 100644 (file)
@@ -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>
index 93fae0d..f7924f0 100644 (file)
@@ -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 (file)
index 0000000..b9769e3
--- /dev/null
@@ -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();
+}