| 1 |
// { dg-additional-options "-std=c++17 -w" } |
| 2 |
|
| 3 |
#include "coro.h" |
| 4 |
|
| 5 |
class await { |
| 6 |
public: |
| 7 |
class promise_type { |
| 8 |
public: |
| 9 |
std::suspend_always initial_suspend() const noexcept { return {}; } |
| 10 |
std::suspend_always final_suspend() const noexcept { return {}; } |
| 11 |
void unhandled_exception() noexcept { } |
| 12 |
await get_return_object() { return await{}; } |
| 13 |
void return_void() {} |
| 14 |
}; |
| 15 |
bool await_ready() const noexcept { return false; } |
| 16 |
bool await_suspend(std::coroutine_handle<>) noexcept {return true;} |
| 17 |
void await_resume() { } |
| 18 |
}; |
| 19 |
|
| 20 |
class mycoro { |
| 21 |
public: |
| 22 |
class promise_type { |
| 23 |
public: |
| 24 |
std::suspend_always initial_suspend() const noexcept { return {}; } |
| 25 |
std::suspend_always final_suspend() const noexcept { return {}; } |
| 26 |
void unhandled_exception() noexcept { } |
| 27 |
mycoro get_return_object() { return mycoro{}; } |
| 28 |
void return_void() {} |
| 29 |
}; |
| 30 |
}; |
| 31 |
mycoro foo(await awaitable) { |
| 32 |
co_return co_await awaitable; |
| 33 |
} |
| 34 |
|
| 35 |
mycoro bar() |
| 36 |
{ |
| 37 |
auto t = [&]() -> await { co_return; }(); |
| 38 |
return foo (t); |
| 39 |
} |
| 40 |
|