[PATCH v2] c++, coroutines: The frame pointer is used in the helpers [PR116482].
Jason Merrill
jason@redhat.com
Mon Aug 26 18:36:20 GMT 2024
On 8/26/24 2:34 PM, Iain Sandoe wrote:
> Hi Jason,
>
>>> 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.
>
>> You also wouldn't get the warning if the param were marked DECL_ARTIFICIAL, which seems desirable anyway?
>
> Yes, done as attached, OK for trunk assuming that reg-testing passes?
OK.
> --- 8< ---
>
> 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 <iain@sandoe.co.uk>
> ---
> gcc/cp/coroutines.cc | 1 +
> gcc/testsuite/g++.dg/coroutines/pr116482.C | 30 ++++++++++++++++++++++
> 2 files changed, 31 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/coroutines/pr116482.C
>
> diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
> index c3e08221cc9..8f899513691 100644
> --- a/gcc/cp/coroutines.cc
> +++ b/gcc/cp/coroutines.cc
> @@ -4058,6 +4058,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 <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;
> +}
More information about the Gcc-patches
mailing list