1 // { dg-do run }
2 
3 // template parm in a class
4 
5 #include "../coro.h"
6 
7 // boiler-plate for tests of codegen
8 #define USE_AWAIT_TRANSFORM
9 #include "../coro1-ret-int-yield-int.h"
10 
11 template <typename T>
12 class foo
13 {
14   public:
meth(T y)15   coro1 meth (T y)
16     {
17       PRINT ("coro1: about to return");
18       T x = y;
19       co_return co_await x + 3;
20     }
21 };
22 
main()23 int main ()
24 {
25   foo<int> inst {};
26   PRINT ("main: create coro1");
27   coro1 x = inst.meth (17);
28   if (x.handle.done())
29     abort();
30 
31   x.handle.resume();
32   PRINT ("main: after resume (initial suspend)");
33 
34   x.handle.resume();
35   PRINT ("main: after resume (co_await)");
36 
37   /* Now we should have the co_returned value.  */
38   int y = x.handle.promise().get_value();
39   if ( y != 20 )
40     {
41       PRINTF ("main: wrong result (%d).", y);
42       abort ();
43     }
44 
45   if (!x.handle.done())
46     {
47       PRINT ("main: apparently not done...");
48       abort ();
49     }
50   PRINT ("main: returning");
51   return 0;
52 }
53