]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/57082 - new X{} and private destructor.
authorJason Merrill <jason@redhat.com>
Fri, 13 Dec 2019 05:10:11 +0000 (00:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Dec 2019 05:10:11 +0000 (00:10 -0500)
build_new_1 already passes tf_no_cleanup to build_value_init, but in this
testcase we end up calling build_value_init by way of
build_special_member_call, so we need to pass it to that function as well.

* init.c (build_new_1): Also pass tf_no_cleanup to
build_special_member_call.

From-SVN: r279335

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/g++.dg/cpp0x/initlist-new2.C [new file with mode: 0644]

index 5b05e84b4c3aa41e256fd98283084ac2dd5b5ccb..5600ebea79813dca2e773f308c1f323c32bdd229 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-11  Jason Merrill  <jason@redhat.com>
+
+       PR c++/57082 - new X{} and private destructor.
+       * init.c (build_new_1): Also pass tf_no_cleanup to
+       build_special_member_call.
+
 2019-12-11  Jason Merrill  <jason@redhat.com>
 
        PR c++/92859 - ADL and bit-field.
index 59e1f351fc69891f6a72a3f930891d8a13d2d4f5..6cd32d9844870927f8e2506a33a6f0e4b4900f95 100644 (file)
@@ -3512,7 +3512,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
                                                     complete_ctor_identifier,
                                                     init, elt_type,
                                                     LOOKUP_NORMAL,
-                                                     complain);
+                                                    complain|tf_no_cleanup);
            }
          else if (explicit_value_init_p)
            {
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-new2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-new2.C
new file mode 100644 (file)
index 0000000..439b8da
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/57082
+// { dg-do compile { target c++11 } }
+
+struct X
+{
+private:
+  ~X() {}
+};
+
+int main()
+{
+  new X;    // OK
+  new X();  // OK
+  new X{};  // { dg-bogus "" }
+}