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