Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/torture/local-var-01-single.C

raw
1 // { dg-do run }
2 // { dg-skip-if "requires hosted libstdc++ for cstdlib abort" { ! hostedlib } }
3
4 // Simplest local var
5
6 #include "../coro.h"
7
8 // boiler-plate for tests of codegen
9 #include "../coro1-ret-int-yield-int.h"
10
11 struct coro1
12 f (int x) noexcept
13 {
14 int answer = x + 6132;
15 PRINTF ("coro1: about to return %d\n", answer);
16 co_return answer;
17 }
18
19 int main ()
20 {
21 PRINT ("main: create coro1");
22 struct coro1 x = f (42);
23 PRINT ("main: got coro1 - resuming");
24 if (x.handle.done())
25 abort();
26 x.handle.resume();
27 PRINT ("main: after resume");
28 int y = x.handle.promise().get_value();
29 if ( y != 6174 )
30 abort ();
31 if (!x.handle.done())
32 {
33 PRINT ("main: apparently not done...");
34 abort ();
35 }
36 PRINT ("main: returning");
37 return 0;
38 }