Debian Codegraph @

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

raw
1 // PR120273
2 // { dg-additional-options "-Wno-literal-suffix" }
3 namespace std {
4 void declval();
5 template < typename > struct invoke_result;
6 template < typename _Fn > using invoke_result_t = invoke_result< _Fn >;
7 template < typename _Derived, typename _Base >
8 concept derived_from = __is_base_of(_Base, _Derived);
9 template < typename, typename >
10 concept convertible_to = requires { declval; };
11 template < char... > int operator""ms();
12 template < typename _Result, typename > struct coroutine_traits : _Result {};
13 template < typename = void > struct coroutine_handle {
14 static coroutine_handle from_address(void *);
15 operator coroutine_handle<>();
16 void *address();
17 };
18 }
19
20 using namespace std;
21
22 template < class > using CoroutineHandle = coroutine_handle<>;
23
24 template < class Callable >
25 requires(derived_from< invoke_result_t< Callable >, int >)
26 Callable operator co_await(Callable);
27
28 struct FinalSuspendProxy {
29 bool await_ready() noexcept;
30 void await_suspend(CoroutineHandle< void >) noexcept ;
31 void await_resume() noexcept;
32 };
33
34 struct Task {
35 struct Promise;
36 using promise_type = Promise;
37
38 struct Promise {
39 auto initial_suspend() { return FinalSuspendProxy(); }
40 auto final_suspend () noexcept { return FinalSuspendProxy(); }
41 void unhandled_exception () {}
42 Task get_return_object () { return {}; }
43 };
44 } ;
45
46 struct TestEventLoop {
47 struct Sleep {
48 Sleep(TestEventLoop, int);
49 bool await_ready();
50 void await_suspend(CoroutineHandle< void >);
51 void await_resume();
52 };
53 auto sleep(int tm) { return Sleep(*this, tm); }
54 };
55
56 Task test_body_11(TestEventLoop t) {
57 co_await t.sleep(5ms);
58 }