testsuite: don't declare printf in coro.h
[official-gcc.git] / gcc / testsuite / g++.dg / coroutines / torture / class-03-operator-templ-parm.C
blob2d888a745586c7619bd53efda0196f5ab2698c29
1 // { dg-do run }
3 // template parm in a class
5 #include "../coro.h"
7 // boiler-plate for tests of codegen
8 #define USE_AWAIT_TRANSFORM
9 #include "../coro1-ret-int-yield-int.h"
11 template <typename T>
12 class foo
14   public:
15   coro1 operator()(T y)
16     {
17       PRINT ("coro1: about to return");
18       T x = y;
19       co_return co_await x + 3;
20     }
23 int main ()
25   foo<int> inst {};
26   PRINT ("main: create coro1");
27   coro1 x = inst.operator()(17);
28   if (x.handle.done())
29     abort();
31   x.handle.resume();
32   PRINT ("main: after resume (initial suspend)");
34   x.handle.resume();
35   PRINT ("main: after resume (co_await)");
37   /* Now we should have the co_returned value.  */
38   int y = x.handle.promise().get_value();
39   if ( y != 20 )
40     {
41       PRINTF ("main: wrong result (%d).", y);
42       abort ();
43     }
45   if (!x.handle.done())
46     {
47       PRINT ("main: apparently not done...");
48       abort ();
49     }
50   PRINT ("main: returning");
51   return 0;