Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/pr94829.C

raw
1
2 namespace std::experimental {
3 template <typename R, typename... T> struct coroutine_traits {
4 using promise_type = typename R::promise_type;
5 };
6
7 template <class Promise = void> struct coroutine_handle;
8 template <> struct coroutine_handle<void> {
9 static coroutine_handle from_address(void *) noexcept;
10 coroutine_handle() = default;
11 template <class PromiseType>
12 coroutine_handle(coroutine_handle<PromiseType>) noexcept;
13 };
14 template <class Promise> struct coroutine_handle : coroutine_handle<void> {
15 coroutine_handle() = default;
16 static coroutine_handle from_address(void *) noexcept;
17 };
18 }
19
20 struct suspend_always {
21 bool await_ready() noexcept;
22 void await_suspend(std::experimental::coroutine_handle<>) noexcept;
23 void await_resume() noexcept;
24 };
25
26 struct Task {
27 struct promise_type {
28 Task get_return_object();
29 void return_void() {}
30 suspend_always initial_suspend() noexcept;
31 suspend_always final_suspend() noexcept;
32 void unhandled_exception() noexcept;
33 };
34 };
35
36 template <typename _AwrT> auto SyncAwait(_AwrT &&A) {
37 if (!A.await_ready()) {
38 auto AwaitAsync = [&]() -> Task {
39 try { (void)(co_await A); } catch (...) {} // { dg-error {coroutines require a traits template; cannot find 'std::coroutine_traits'} }
40 };
41 Task t = AwaitAsync();
42 }
43 return A.await_resume();
44 }
45
46 void f() {
47 suspend_always test;
48 SyncAwait(test);
49 }