coroutines: Emit error for invalid promise return types [PR97438].
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 17 Oct 2020 10:21:11 +0000 (11:21 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Mon, 19 Oct 2020 19:22:37 +0000 (20:22 +0100)
commitb003c4b14b3f889e6707db68d2c6545eda7a203b
tree225cf2cb2538ac0e3bdfd2913e18966553e99e03
parent619f91eaa8c8a50f1f9d3e7b96ee837037f0e806
coroutines: Emit error for invalid promise return types [PR97438].

At one stage, use cases were proposed for allowing the promise
type to contain both return_value and return_void.  That was
not accepted into C++20, so we should reject it as per the PR.

gcc/cp/ChangeLog:

PR c++/97438
* coroutines.cc (struct coroutine_info): Add a field to
record that we emitted a promise type error.
(coro_promise_type_found_p): Check for the case that the
promise type contains both return_void and return_value.
Emit an error if so, with information about the wrong
type methods.

gcc/testsuite/ChangeLog:

PR c++/97438
* g++.dg/coroutines/pr97438.C: New test.
gcc/cp/coroutines.cc
gcc/testsuite/g++.dg/coroutines/pr97438.C [new file with mode: 0644]