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: r279236
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.
+
PR c++/92774 - ICE with implicitly deleted operator<=>.
* method.c (comp_info::~comp_info): Factor out of...
(build_comparison_op): Here. Handle error return from build_new_op.
complete_ctor_identifier,
init, elt_type,
LOOKUP_NORMAL,
- complain);
+ complain|tf_no_cleanup);
}
else if (explicit_value_init_p)
{
--- /dev/null
+// PR c++/57082
+// { dg-do compile { target c++11 } }
+
+struct X
+{
+private:
+ ~X() {}
+};
+
+int main()
+{
+ new X; // OK
+ new X(); // OK
+ new X{}; // ERROR
+}