1 //  { dg-do run }
2 
3 #include "../coro.h"
4 
5 struct pt_b
6 {
initial_suspendpt_b7   std::suspend_always initial_suspend() const noexcept { return {}; }
final_suspendpt_b8   std::suspend_always final_suspend() const noexcept { return {}; }
return_voidpt_b9   constexpr void return_void () noexcept {};
unhandled_exceptionpt_b10   constexpr void unhandled_exception() const noexcept {}
11 };
12 
13 int called_gro_op = 0;
14 
15 template<typename R, typename HandleRef, typename ...T>
16 struct std::coroutine_traits<R, HandleRef, T...> {
17   struct pt_c;
18   using promise_type = pt_c;
19   struct pt_c : pt_b {
20     //using handle_t = std::coroutine_handle<pt_c>;
21     pt_c (HandleRef h, T ...args)
22     {  h = std::coroutine_handle<pt_c>::from_promise (*this);
23        PRINT ("Created Promise");
24        //g_promise = 1;
25     }
26     struct gro
27       {
28         auto operator ()() {
29         PRINT("call to operator ");
30         called_gro_op++;
31         }
32       };
33     gro get_return_object;
34   };
35 };
36 
37 static void
38 foo (std::coroutine_handle<>& h)
39 {
40   co_return;
41 }
42 
43 int main ()
44 {
45   std::coroutine_handle<> f;
46   foo (f);
47   if (f.done())
48     {
49       PRINT ("unexpected finished foo coro");
50       abort ();
51    }
52   f.resume();
53   if (!f.done())
54     {
55       PRINT ("expected foo to be finished");
56       abort ();
57    }
58 
59   if (called_gro_op != 1)
60     {
61       PRINT ("Failed to call gro op");
62       abort ();
63    }
64 }
65