https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119699
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #4) > (In reply to Andrew Pinski from comment #3) > > Yes because REG_RETURNED does not work always. I will file a new bug for > > that. > > PR 120214 . > > As for tail call, that is a different issue; I have not fully looked into > yet. > Cannot tail-call: call and return value are different: x::x (_2(D)); > > The call flags are definitely set but I will need to debug what is going > wrong. Oh it is on the function type rather than the decl. So this works for the tail call testcase in comment #1: ``` diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 03e8c98d4b6..c1a9b22454b 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -14370,6 +14370,16 @@ grokdeclarator (const cp_declarator *declarator, else returned_attrs = attr_chainon (returned_attrs, att); } + if (inner_declarator + && inner_declarator->kind == cdk_id + && (inner_declarator->u.id.sfk == sfk_destructor + || inner_declarator->u.id.sfk == sfk_constructor) + && targetm.cxx.cdtor_returns_this ()) + { + attrs = tree_cons (get_identifier ("fn spec"), + build_tree_list (NULL_TREE, build_string (2, "1 ")), + attrs); + } /* Actually apply the contract attributes to the declaration. */ for (tree *p = &attrs; *p;) ```