testsuite: don't declare printf in coro.h
[official-gcc.git] / gcc / testsuite / g++.dg / coroutines / torture / local-var-02-conditional.C
blobf232edabdae42dd7f142bd49e59c2a849bfe7d9b
1 //  { dg-do run }
3 // Test local vars in nested scopes
5 #include "../coro.h"
7 // boiler-plate for tests of codegen
8 #include "../coro1-ret-int-yield-int.h"
10 struct coro1
11 f (int x) noexcept
13   int y = x;
14   const int test = 20;
15   if (y > test)
16     {
17       int fred = y - 20;
18       PRINTF ("coro1: about to return %d\n", fred);
19       co_return fred;
20     }
21   else
22     {
23       PRINT ("coro1: about to return the answer\n");
24       co_return y;
25     }
27   co_return x;
30 int main ()
32   PRINT ("main: create coro1");
33   struct coro1 x = f (6194);
34   PRINT ("main: got coro1 - resuming");
35   if (x.handle.done())
36     abort();
37   x.handle.resume();
38   PRINT ("main: after resume");
39   int y = x.handle.promise().get_value();
40   if ( y != 6174 )
41     abort ();
42   if (!x.handle.done())
43     {
44       PRINT ("main: apparently not done...");
45       abort ();
46       //x.handle.resume();
47     }
48   PRINT ("main: returning");
49   return 0;