As the PR notes, we now have two bogus warnings that the single frame pointer parameter is unused in each of the helper functions.
This started when we began to use start_preparsed_function/finish_function to wrap the helper function code generation. I am puzzled a little about why the use is not evident without marking - or perhaps it is always needed to mark use in synthetic code? For the destroy function, in particular, the use of the parameter is simple - an indirect ref and then it is passed to the call to the actor. The fix here is somewhat trivial - to mark the param as used as soon as it is. Tested on x86_64-darwin, reg-strapping on x86_64-darwin/linux and powerpc64 linux, OK for trunk assuming that the reg-straps are successful? thanks Iain --- 8< --- We have a bogus warning about the coroutine state frame pointers being apparently unused in the resume and destroy functions. Fixed thus. PR c++/116482 gcc/cp/ChangeLog: * coroutines.cc (build_actor_fn): Mark the frame pointer as used. (build_destroy_fn): Likewise. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr116482.C: New test. Signed-off-by: Iain Sandoe <i...@sandoe.co.uk> --- gcc/cp/coroutines.cc | 3 ++- gcc/testsuite/g++.dg/coroutines/pr116482.C | 30 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/coroutines/pr116482.C diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index c3e08221cc9..3dee844ad4e 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -2255,6 +2255,7 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor, tree fnbody, tree actor_begin_label = create_named_label_with_ctx (loc, "actor.begin", actor); tree actor_frame = build1_loc (loc, INDIRECT_REF, coro_frame_type, actor_fp); + mark_used (actor_fp); /* Declare the continuation handle. */ add_decl_expr (continuation); @@ -2526,7 +2527,7 @@ build_destroy_fn (location_t loc, tree coro_frame_type, tree destroy, tree destr_frame = cp_build_indirect_ref (loc, destr_fp, RO_UNARY_STAR, tf_warning_or_error); - + mark_used (destr_fp); tree rat_field = lookup_member (coro_frame_type, coro_resume_index_id, 1, 0, tf_warning_or_error); tree rat diff --git a/gcc/testsuite/g++.dg/coroutines/pr116482.C b/gcc/testsuite/g++.dg/coroutines/pr116482.C new file mode 100644 index 00000000000..702d1e235bb --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr116482.C @@ -0,0 +1,30 @@ +// Override default options. +// { dg-options "-std=c++20 -fno-exceptions -Wall -Wextra" } + +#include <coroutine> + +struct SuspendNever { + bool await_ready(); + void await_suspend(std::coroutine_handle<>); + void await_resume(); +}; + +struct Coroutine; + +struct PromiseType { + Coroutine get_return_object(); + SuspendNever initial_suspend(); + SuspendNever final_suspend(); +#if __cpp_exceptions + void unhandled_exception() { /*std::terminate();*/ }; +#endif + void return_void(); +}; + +struct Coroutine { + using promise_type = PromiseType; +}; + +Coroutine __async_test_input_basic() { + co_return; +} -- 2.39.2 (Apple Git-143)