On 7/13/26 5:34 PM, Yuxuan Chen wrote:
From: Yuxuan Chen <[email protected]>Constructor and destructor clones already have a genericized copy of the original body, including parameter cleanups. Do not add another front-end CLEANUP_STMT while processing a clone. gcc/cp/ChangeLog: PR c++/125066 * decl.cc (store_parm_decls): Do not register trivial_abi parameter cleanups for cloned functions.
Pushed, thanks!
gcc/testsuite/ChangeLog: PR c++/125066 * g++.dg/cpp0x/attr-trivial_abi10.C: New test. Signed-off-by: Yuxuan Chen <[email protected]> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index a2233107317..e1391ddfd0b 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -20276,7 +20276,7 @@ store_parm_decls (tree current_function_parms)/* Register cleanups for parameters with trivial_abi attribute, the cleanupof which is the callee's responsibility. */ - if (!processing_template_decl) + if (!processing_template_decl && !DECL_CLONED_FUNCTION_P (fndecl)) for (tree parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm)) { if (TREE_CODE (parm) == PARM_DECL) diff --git a/gcc/testsuite/g++.dg/cpp0x/attr-trivial_abi10.C b/gcc/testsuite/g++.dg/cpp0x/attr-trivial_abi10.C new file mode 100644 index 00000000000..5e0b2ffdf5c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/attr-trivial_abi10.C @@ -0,0 +1,14 @@ +// PR c++/125066 +// { dg-do compile { target c++11 } } + +class Callback; +struct Handler { + Handler(Callback); +}; +struct [[clang::trivial_abi]] Holder { + ~Holder(); +}; +struct [[clang::trivial_abi]] Callback { + Holder holder; +}; +Handler::Handler(Callback) {}
