]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++, coroutines: Improve diagnostics for awaiter/promise.
authorIain Sandoe <iain@sandoe.co.uk>
Thu, 29 May 2025 15:50:44 +0000 (16:50 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Sat, 14 Jun 2025 10:40:55 +0000 (11:40 +0100)
commit4c014a9db521b24bd900eb9a6ac70988322a57da
tree9532707f32caa59e15caa8efe82b60ecf0abef09
parent48cf37876206a3c660ef72957605ac99cf240759
c++, coroutines: Improve diagnostics for awaiter/promise.

At present, we can issue diagnostics about missing or malformed
awaiter or promise methods when we encounter their uses in the
body of a user's function.  We might then re-issue the same
diagnostics when processing the initial or final await expressions.

This change avoids such duplication, and also attempts to
identify issues with the initial or final expressions specifically
since diagnostics for those do not have any useful line number.

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Identify diagnostics
for initial and final await expressions.
(cp_coroutine_transform::wrap_original_function_body): Do
not handle initial and final await expressions here ...
(cp_coroutine_transform::apply_transforms): ... handle them
here and avoid duplicate diagnostics.
* coroutines.h: Declare inital and final await expressions
in the transform class.  Save the function closing brace
location.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/coro1-missing-await-method.C: Adjust for
improved diagnostics.
* g++.dg/coroutines/coro-missing-final-suspend.C: Likewise.
* g++.dg/coroutines/pr104051.C: Move to...
* g++.dg/coroutines/pr104051-0.C: ...here.
* g++.dg/coroutines/pr104051-1.C: New test.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cp/coroutines.cc
gcc/cp/coroutines.h
gcc/testsuite/g++.dg/coroutines/coro-missing-final-suspend.C
gcc/testsuite/g++.dg/coroutines/coro1-missing-await-method.C
gcc/testsuite/g++.dg/coroutines/pr104051-0.C [moved from gcc/testsuite/g++.dg/coroutines/pr104051.C with 89% similarity]
gcc/testsuite/g++.dg/coroutines/pr104051-1.C [new file with mode: 0644]