testsuite: don't declare printf in coro.h
[official-gcc.git] / gcc / testsuite / g++.dg / coroutines / torture / co-await-13-return-ref.C
blob78f2d5b9d1b981660c06a01e3acf7838b76d7898
1 //  { dg-do run }
3 /* The simplest valued co_await we can do.  */
5 #include "../coro.h"
7 // boiler-plate for tests of codegen
8 #include "../coro1-ret-int-yield-int.h"
10 int gX = 1;
12 coro1
13 f ()
15   int t = 5;
16   gX = co_await coro1::suspend_always_intrefprt{t};
17   co_return t + 10;
20 int main ()
22   PRINT ("main: create coro1");
23   struct coro1 f_coro = f ();
24   PRINT ("main: got coro1 - checking gX");
25   if (gX != 1)
26     {
27       PRINTF ("main: gX is wrong : %d, should be 1\n", gX);
28       abort ();
29     }
30   if (f_coro.handle.done())
31     {
32       PRINT ("main: we should not be 'done' [1]");
33       abort ();
34     }
35   PRINT ("main: resuming [1] initial suspend");
36   f_coro.handle.resume();
37   PRINT ("main: resuming [2] co_await suspend_always_intprt");
38   f_coro.handle.resume();
39   if (gX != 5)
40     {
41       PRINTF ("main: gX is wrong : %d, should be 5\n", gX);
42       abort ();
43     }
44   /* we should now have returned with the co_return (15) */
45   if (!f_coro.handle.done())
46     {
47       PRINT ("main: we should be 'done' ");
48       abort ();
49     }
50   int y = f_coro.handle.promise().get_value();
51   if (y != 15)
52     {
53       PRINTF ("main: y is wrong : %d, should be 15\n", y);
54       abort ();
55     }
56   PRINT ("main: done");
57   return 0;