summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-17 15:52:21 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-17 15:52:21 +0000
commit8d47c1c56c9db6161f71ae6ca2c7a8ea58245e80 (patch)
treec6e2dd122287481cd4564e2e3db336f69861441d
parent9e9cc1a9a4a4809a4d0cf4fdcf0ae74298cca6a4 (diff)
downloadgcc-8d47c1c56c9db6161f71ae6ca2c7a8ea58245e80.tar.gz
[C++ PATCH 82560] missing dtor call
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg01068.html PR c++/82560 * call.c (build_over_call): Don't pass tf_no_cleanup to nested calls. PR c++/82560 * g++.dg/cpp0x/pr82560.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253820 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/call.c11
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr82560.C28
4 files changed, 42 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 621efed82ac..daf302fc349 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2017-10-17 Nathan Sidwell <nathan@acm.org>
+ PR c++/82560
+ * call.c (build_over_call): Don't pass tf_no_cleanup to nested
+ calls.
+
PR middle-end/82546
* cp-objcp-common.c (cp_tree_size): Reformat. Adjust returns size
of TYPE nodes.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 13269024547..8f33ab51690 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7717,8 +7717,11 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
}
/* N3276 magic doesn't apply to nested calls. */
- int decltype_flag = (complain & tf_decltype);
+ tsubst_flags_t decltype_flag = (complain & tf_decltype);
complain &= ~tf_decltype;
+ /* No-Cleanup doesn't apply to nested calls either. */
+ tsubst_flags_t no_cleanup_complain = complain;
+ complain &= ~tf_no_cleanup;
/* Find maximum size of vector to hold converted arguments. */
parmlen = list_length (parm);
@@ -7916,7 +7919,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
if (flags & LOOKUP_NO_CONVERSION)
conv->user_conv_p = true;
- tsubst_flags_t arg_complain = complain & (~tf_no_cleanup);
+ tsubst_flags_t arg_complain = complain;
if (!conversion_warning)
arg_complain &= ~tf_warning;
@@ -8164,7 +8167,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
else if (default_ctor_p (fn))
{
if (is_dummy_object (argarray[0]))
- return force_target_expr (DECL_CONTEXT (fn), void_node, complain);
+ return force_target_expr (DECL_CONTEXT (fn), void_node,
+ no_cleanup_complain);
else
return cp_build_indirect_ref (argarray[0], RO_NULL, complain);
}
@@ -9062,7 +9066,6 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
static member function. */
instance = mark_type_use (instance);
-
/* Figure out whether to skip the first argument for the error
message we will display to users if an error occurs. We don't
want to display any compiler-generated arguments. The "this"
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 694c23bd171..f344a46479c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2017-10-17 Nathan Sidwell <nathan@acm.org>
+ PR c++/82560
+ * g++.dg/cpp0x/pr82560.C: New.
+
PR middle-end/82577
* g++.dg/opt/pr82577.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr82560.C b/gcc/testsuite/g++.dg/cpp0x/pr82560.C
new file mode 100644
index 00000000000..3408bae518e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr82560.C
@@ -0,0 +1,28 @@
+// { dg-do run { target c++11 } }
+// PR82560, failed to destruct default arg inside new
+
+static int liveness = 0;
+
+struct Foo {
+
+ Foo (int) {
+ liveness++;
+ }
+
+ ~Foo() {
+ liveness--;
+ }
+
+};
+
+struct Bar {
+ Bar (Foo = 0) { }
+ ~Bar() { }
+};
+
+int main()
+{
+ delete new Bar();
+
+ return liveness != 0;;
+}