145
|
1 // { dg-do run }
|
|
2
|
|
3 // Test returning an int.
|
|
4 // We will use the promise to contain this to avoid having to include
|
|
5 // additional C++ headers.
|
|
6
|
|
7 #include "../coro.h"
|
|
8
|
|
9 // boiler-plate for tests of codegen
|
|
10 #include "../coro1-ret-int-yield-int.h"
|
|
11
|
|
12 struct coro1
|
|
13 f () noexcept
|
|
14 {
|
|
15 PRINT ("coro1: about to return");
|
|
16 co_return 42;
|
|
17 }
|
|
18
|
|
19 int main ()
|
|
20 {
|
|
21 PRINT ("main: create coro1");
|
|
22 struct coro1 x = f ();
|
|
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 != 42 )
|
|
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 }
|