On 8/2/24 6:50 AM, Iain Sandoe wrote:
This fixes a (so far unreported) bug where we would handle noexcept ramps
correctly, but omit exception specs - take this opportunity to simplify.
Tested on x86_64-darwin, OK for trunk?
thanks
Iain

--- 8< ---

We need to separate the original user-authored function body from the
definition of the ramp function (which is what is called instead).
The function body tree is either in DECL_SAVED_TREE or the first operand
of current_eh_spec_block (for functions with an EH spec).
This version simplifies the process by extrating the second case directly

typo

instead of inspecting the DECL_SAVED_TREE trees to discover it.

gcc/cp/ChangeLog:

        * coroutines.cc (use_eh_spec_block): New.
        (split_coroutine_body_from_ramp): New.
        (morph_fn_to_coro): Use split_coroutine_body_from_ramp().

Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>
---
  gcc/cp/coroutines.cc | 97 ++++++++++++++++++++++++--------------------
  1 file changed, 52 insertions(+), 45 deletions(-)

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index af03f5e0f74..fc80a4ec24c 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -4437,6 +4437,50 @@ coro_rewrite_function_body (location_t fn_start, tree 
fnbody, tree orig,
    return update_body;
  }
+static bool
+use_eh_spec_block (tree fn)
+{
+  return (flag_exceptions && flag_enforce_eh_specs
+         && !type_throw_all_p (TREE_TYPE (fn)));
+}

Rather than (partially) duplicate this function, let's make the one in decl.cc non-static.

+/* Extract the body of the function we are going to outline, leaving
+   to original function decl ready to build the ramp.  */
+
+static tree
+split_coroutine_body_from_ramp (tree fndecl, tree eh_spec_block)

Rather than pass current_eh_spec_block into this function through a parameter, why not refer to it directly?

Jason

Reply via email to