Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/torture/lambda-00-co-ret.C

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