]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: add __is_*destructible builtins [PR107600]
authorJason Merrill <jason@redhat.com>
Wed, 28 May 2025 15:42:00 +0000 (11:42 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 29 May 2025 00:46:53 +0000 (20:46 -0400)
commit0629924777ea20d56d9ea40c3915eb0327a22ac7
treed95d8a2935e191d6e0ab633937c23dd9f2e671ca
parent7fca794e0199baff8f07140a950ba3374c6aa634
c++: add __is_*destructible builtins [PR107600]

Typically "does this class have a trivial destructor" is the wrong question
to ask, we rather want "can I destroy this class trivially", thus the
std::is_trivially_destructible standard trait.  Let's provide a builtin for
it, and complain about asking whether a deleted destructor is trivial.

Clang and MSVC also have these traits.

PR c++/107600

gcc/cp/ChangeLog:

* cp-trait.def (IS_DESTRUCTIBLE, IS_NOTHROW_DESTRUCTIBLE)
(IS_TRIVIALLY_DESTRUCTIBLE): New.
* constraint.cc (diagnose_trait_expr): Explain them.
* method.cc (destructible_expr): New.
(is_xible_helper): Use it.
* semantics.cc (finish_trait_expr): Handle new traits.
(trait_expr_value): Likewise.  Complain about asking
whether a deleted dtor is trivial.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_destructible1.C: New test.
gcc/cp/constraint.cc
gcc/cp/cp-trait.def
gcc/cp/method.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/ext/is_destructible1.C [new file with mode: 0644]