| 1 |
// { dg-additional-options "-fsyntax-only" } |
| 2 |
namespace std { |
| 3 |
template <class T, class = void> |
| 4 |
struct traits_sfinae_base {}; |
| 5 |
|
| 6 |
template <class Ret, class... Args> |
| 7 |
struct coroutine_traits : public traits_sfinae_base<Ret> {}; |
| 8 |
} |
| 9 |
|
| 10 |
template<typename Promise> struct coro {}; |
| 11 |
template <typename Promise, typename... Ps> |
| 12 |
struct std::coroutine_traits<coro<Promise>, Ps...> { |
| 13 |
using promise_type = Promise; |
| 14 |
}; |
| 15 |
|
| 16 |
struct awaitable { |
| 17 |
bool await_ready() noexcept; |
| 18 |
template <typename F> |
| 19 |
void await_suspend(F) noexcept; |
| 20 |
void await_resume() noexcept; |
| 21 |
} a; |
| 22 |
|
| 23 |
struct suspend_always { |
| 24 |
bool await_ready() noexcept { return false; } |
| 25 |
template <typename F> |
| 26 |
void await_suspend(F) noexcept; |
| 27 |
void await_resume() noexcept {} |
| 28 |
}; |
| 29 |
|
| 30 |
namespace std { |
| 31 |
template <class PromiseType = void> |
| 32 |
struct coroutine_handle { |
| 33 |
static coroutine_handle from_address(void*); |
| 34 |
void* address(); |
| 35 |
}; |
| 36 |
} |
| 37 |
|
| 38 |
struct bad_promise_6 { |
| 39 |
coro<bad_promise_6> get_return_object(); |
| 40 |
suspend_always initial_suspend(); |
| 41 |
suspend_always final_suspend() noexcept; |
| 42 |
void unhandled_exception(); |
| 43 |
void return_void(); |
| 44 |
void return_value(int) const; |
| 45 |
void return_value(int); |
| 46 |
}; |
| 47 |
|
| 48 |
coro<bad_promise_6> |
| 49 |
bad_implicit_return() // { dg-error {.aka 'bad_promise_6'. declares both 'return_value' and 'return_void'} } |
| 50 |
{ |
| 51 |
co_await a; |
| 52 |
} |