| 1 |
// { dg-additional-options "-Wall -O" } |
| 2 |
|
| 3 |
// This should complete without any diagnostic. |
| 4 |
|
| 5 |
#include <coroutine> |
| 6 |
#include <exception> |
| 7 |
|
| 8 |
template <typename T> |
| 9 |
class lazy { |
| 10 |
T _v = 0; |
| 11 |
public: |
| 12 |
lazy() {} |
| 13 |
bool await_ready() {return true;} |
| 14 |
void await_suspend(auto x) noexcept {} |
| 15 |
T await_resume() { return _v; } |
| 16 |
}; |
| 17 |
|
| 18 |
namespace std { |
| 19 |
|
| 20 |
template <typename T, typename... Args> |
| 21 |
struct coroutine_traits<lazy<T>, Args...> { |
| 22 |
struct promise_type { |
| 23 |
suspend_always initial_suspend() const { return {}; } |
| 24 |
suspend_always final_suspend() const noexcept { return {}; } |
| 25 |
void return_value(T val) {} |
| 26 |
lazy<T> get_return_object() { |
| 27 |
return lazy<T>(); |
| 28 |
} |
| 29 |
void unhandled_exception() { |
| 30 |
std::terminate(); |
| 31 |
} |
| 32 |
}; |
| 33 |
}; |
| 34 |
} |
| 35 |
|
| 36 |
struct xxx { |
| 37 |
static lazy<int> func() { |
| 38 |
co_return 1; |
| 39 |
} |
| 40 |
}; |
| 41 |
|
| 42 |
#if 0 |
| 43 |
lazy<int> foo() { |
| 44 |
co_return co_await xxx::func(); |
| 45 |
} |
| 46 |
#endif |