Implement P0722R3, destroying operator delete.
authorJason Merrill <jason@redhat.com>
Tue, 13 Nov 2018 04:40:01 +0000 (23:40 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 Nov 2018 04:40:01 +0000 (23:40 -0500)
commita6bb6b07f76c4431cb5a2a520ac33f7c970b80c1
tree4da8d10f970dd37ab850c548d36cd4980e9a623d
parent7de37c97b4031ba61c867cf6fadf63916c666894
Implement P0722R3, destroying operator delete.

A destroying operator delete takes responsibility for calling the destructor
for the object it is deleting; this is intended to be useful for sized
delete of a class allocated with a trailing buffer, where the compiler can't
know the size of the allocation, and so would pass the wrong size to the
non-destroying sized operator delete.

gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): Define
__cpp_impl_destroying_delete.
gcc/cp/
* call.c (std_destroying_delete_t_p, destroying_delete_p): New.
(aligned_deallocation_fn_p, usual_deallocation_fn_p): Use
destroying_delete_p.
(build_op_delete_call): Handle destroying delete.
* decl2.c (coerce_delete_type): Handle destroying delete.
* init.c (build_delete): Don't call dtor with destroying delete.
* optimize.c (build_delete_destructor_body): Likewise.
libstdc++-v3/
* libsupc++/new (std::destroying_delete_t): New.

From-SVN: r266053
13 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c-cppbuiltin.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/init.c
gcc/cp/optimize.c
gcc/testsuite/g++.dg/cpp2a/destroying-delete1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/feat-cxx2a.C
libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/new