| 1 |
// { dg-do compile } |
| 2 |
#include <coroutine> |
| 3 |
|
| 4 |
struct must_check_result |
| 5 |
{ |
| 6 |
bool await_ready() { return false; } |
| 7 |
void await_suspend(std::coroutine_handle<>) {} |
| 8 |
[[nodiscard]] bool await_resume() { return {}; } |
| 9 |
}; |
| 10 |
|
| 11 |
struct task {}; |
| 12 |
|
| 13 |
namespace std |
| 14 |
{ |
| 15 |
template<typename... Args> |
| 16 |
struct coroutine_traits<task, Args...> |
| 17 |
{ |
| 18 |
struct promise_type |
| 19 |
{ |
| 20 |
task get_return_object() { return {}; } |
| 21 |
suspend_always initial_suspend() noexcept { return {}; } |
| 22 |
suspend_always final_suspend() noexcept { return {}; } |
| 23 |
void return_void() {} |
| 24 |
void unhandled_exception() {} |
| 25 |
}; |
| 26 |
}; |
| 27 |
} |
| 28 |
|
| 29 |
task example(auto) |
| 30 |
{ |
| 31 |
co_await must_check_result(); // { dg-warning "-Wunused-result" } |
| 32 |
} |
| 33 |
|
| 34 |
void f() { example(1); } |