From: Iain Sandoe Date: Mon, 26 Aug 2024 13:09:40 +0000 (+0100) Subject: c++, coroutines: The frame pointer is used in the helpers [PR116482]. X-Git-Tag: releases/gcc-14.3.0~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2fa7e036e72fa0ed63df602cebd4005b078336e;p=thirdparty%2Fgcc.git c++, coroutines: The frame pointer is used in the helpers [PR116482]. We have a bogus warning about the coroutine state frame pointers being apparently unused in the resume and destroy functions. Fixed by making the parameters DECL_ARTIFICIAL. PR c++/116482 gcc/cp/ChangeLog: * coroutines.cc (coro_build_actor_or_destroy_function): Make the parameter decls DECL_ARTIFICIAL. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr116482.C: New test. Signed-off-by: Iain Sandoe (cherry picked from commit 8d6d6c864442a1cc987b3e6bcb1d903ceb975e4a) --- diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 953297c3c49..8bb46ff5c99 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -4226,6 +4226,7 @@ coro_build_actor_or_destroy_function (tree orig, tree fn_type, tree id = get_identifier ("frame_ptr"); tree fp = build_lang_decl (PARM_DECL, id, coro_frame_ptr); + DECL_ARTIFICIAL (fp) = true; DECL_CONTEXT (fp) = fn; DECL_ARG_TYPE (fp) = type_passed_as (coro_frame_ptr); DECL_ARGUMENTS (fn) = fp; 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 + +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; +}