Debian Codegraph @

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

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