| 1 |
// { dg-do run { target c++20 } } |
| 2 |
// test case from pr106188, w/o workaround |
| 3 |
#include <coroutine> |
| 4 |
|
| 5 |
struct task { |
| 6 |
struct promise_type { |
| 7 |
task get_return_object() { return task{}; } |
| 8 |
void return_void() {} |
| 9 |
void unhandled_exception() {} |
| 10 |
auto initial_suspend() noexcept { return std::suspend_never{}; } |
| 11 |
auto final_suspend() noexcept { return std::suspend_never{}; } |
| 12 |
}; |
| 13 |
}; |
| 14 |
|
| 15 |
struct suspend_and_resume { |
| 16 |
bool await_ready() const { return false; } |
| 17 |
void await_suspend(std::coroutine_handle<> h) { h.resume(); } |
| 18 |
void await_resume() {} |
| 19 |
}; |
| 20 |
|
| 21 |
task f() { |
| 22 |
if (co_await suspend_and_resume{}, false) {} |
| 23 |
} |
| 24 |
|
| 25 |
task g() { |
| 26 |
switch (co_await suspend_and_resume{}, 0) { |
| 27 |
default: break; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
int main() { |
| 32 |
f(); |
| 33 |
g(); |
| 34 |
} |