145
|
1 // { dg-do run }
|
|
2
|
|
3 /* The simplest valued co_await we can do. */
|
|
4
|
|
5 #include "../coro.h"
|
|
6
|
|
7 // boiler-plate for tests of codegen
|
|
8 #include "../coro1-ret-int-yield-int.h"
|
|
9
|
|
10
|
|
11 coro1
|
|
12 f ()
|
|
13 {
|
|
14 int t1 = 5;
|
|
15 int t2 = 5;
|
|
16 auto gX = co_await coro1::suspend_always_intrefprt{t1};
|
|
17 if (gX != t1)
|
|
18 abort();
|
|
19 decltype(auto) gX1 = co_await coro1::suspend_always_intrefprt{t2};
|
|
20 if (&gX1 != &t2)
|
|
21 abort();
|
|
22 co_return t1 + 10;
|
|
23 }
|
|
24
|
|
25 int main ()
|
|
26 {
|
|
27 PRINT ("main: create coro1");
|
|
28 struct coro1 f_coro = f ();
|
|
29 if (f_coro.handle.done())
|
|
30 {
|
|
31 PRINT ("main: we should not be 'done' [1]");
|
|
32 abort ();
|
|
33 }
|
|
34 PRINT ("main: resuming [1] initial suspend");
|
|
35 while (!f_coro.handle.done())
|
|
36 f_coro.handle.resume();
|
|
37 /* we should now have returned with the co_return (15) */
|
|
38 if (!f_coro.handle.done())
|
|
39 {
|
|
40 PRINT ("main: we should be 'done' ");
|
|
41 abort ();
|
|
42 }
|
|
43 puts ("main: done");
|
|
44 return 0;
|
|
45 }
|