testsuite: don't declare printf in coro.h
[official-gcc.git] / gcc / testsuite / g++.dg / coroutines / torture / co-await-03-rhs-op.C
blob29dcc5f7a2cd27c67914e14af03c56da3cfe54ad
1 //  { dg-do run }
3 // Basic check of co_await with an expression to await transform.
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 int gX = 1;
13 coro1
14 f ()
16   gX = co_await 11 + 15;
17   co_return gX + 16;
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 [1] await");
38   f_coro.handle.resume();
39   if (gX != 26)
40     {
41       PRINTF ("main: gX is wrong : %d, should be 26\n", gX);
42       abort ();
43     }
44   /* we should now have returned with the co_return (26+16) */
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 != 42)
52     {
53       PRINTF ("main: y is wrong : %d, should be 42\n", y);
54       abort ();
55     }
56   PRINT ("main: done");
57   return 0;