1 // { dg-do run }
2 
3 // Check type dependent function parms.
4 
5 #include "../coro.h"
6 
7 // boiler-plate for tests of codegen
8 // there is a promise ctor that takes a single int.
9 #include "../coro1-ret-int-yield-int.h"
10 
11 template <typename T, typename U, typename V>
12 coro1
f(T x,U y,V z)13 f (T x, U y, V z) noexcept
14 {
15   PRINT ("coro1: about to return");
16   T xi = (T) y;
17   T yi = (T) z;
18   T zi = x;
19   co_return 3 + xi + yi + zi;
20 }
21 
main()22 int main ()
23 {
24   PRINT ("main: create coro1");
25   struct coro1 x = f<int, float, double>(2, 18.0F, 19.0);
26 
27   /* We should be using the default promise ctor, which sets the value
28      to -1.  */
29   int y = x.handle.promise().get_value();
30   if ( y != -1 )
31     {
32       PRINT ("main: wrong promise init.");
33       abort ();
34     }
35 
36   PRINT ("main: got coro1 - resuming");
37   if (x.handle.done())
38     abort();
39 
40   x.handle.resume();
41   PRINT ("main: after resume (initial suspend)");
42 
43   /* Now we should have the co_returned value.  */
44   y = x.handle.promise().get_value();
45   if ( y != 42 )
46     {
47       PRINT ("main: wrong answer.");
48       abort ();
49     }
50 
51   if (!x.handle.done())
52     {
53       PRINT ("main: apparently not done...");
54       abort ();
55     }
56   PRINT ("main: returning");
57   return 0;
58 }
59