]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Mark replaceable global operator new/delete with const std::nothrow_t& argument...
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Nov 2024 07:58:28 +0000 (08:58 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Nov 2024 07:58:28 +0000 (08:58 +0100)
commitc1bbad07c8686c858ea58ffdb9db8f964bf485c6
tree6498873720d75cfac2cde4599529df9b01676a72
parentea46a216d48597b220ae69e79f6513c763f953be
c++: Mark replaceable global operator new/delete with const std::nothrow_t& argument as DECL_IS_REPLACEABLE_OPERATOR [PR117370]

cxx_init_decl_processing predeclares 12 out of the 20 replaceable global
new/delete operators and sets DECL_IS_REPLACEABLE_OPERATOR on those.
But it doesn't handle the remaining 8, in particular
void* operator new(std::size_t, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t, const std::nothrow_t&) noexcept;
void operator delete(void*, const std::nothrow_t&) noexcept;
void operator delete[](void*, const std::nothrow_t&) noexcept;
void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) noexcept;
void operator delete(void*, std::align_val_t, const std::nothrow_t&) noexcept;
void operator delete[](void*, std::align_val_t, const std::nothrow_t&) noexcept;

The following patch sets that flag during grok_op_properties for those, so
that they don't need to be predeclared.
The patch doesn't fix the whole PR, as some work is needed on the CDDCE side
too, unlike the throwing operator new case the if (ptr) conditional around
operator delete isn't removed by VRP and so we need to handle conditional
delete for unconditional new.

2024-11-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/117370
* cp-tree.h (is_std_class): Declare.
* constexpr.cc (is_std_class): New function.
(is_std_allocator): Use it.
* decl.cc (grok_op_properties): Mark global replaceable
operator new/delete operators with const std::nothrow_t & last
argument with DECL_IS_REPLACEABLE_OPERATOR.
gcc/cp/constexpr.cc
gcc/cp/cp-tree.h
gcc/cp/decl.cc