comparison gcc/testsuite/g++.dg/coroutines/torture/co-await-15-return-non-triv.C @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
comparison
equal deleted inserted replaced
145:1830386684a0 152:2b5abeee2509
1 // { dg-do run }
2
3 /* Check that we handle await_resume for a non-trivial type. */
4
5 #include "../coro.h"
6
7 // boiler-plate for tests of codegen
8 #include "../coro1-ret-int-yield-int.h"
9
10 coro1
11 f ()
12 {
13 struct test {
14 int a;
15 ~test () {}
16 };
17 test input{5};
18 test res = co_await coro1::suspend_always_tmpl_awaiter<test>(input);
19 co_return res.a + 10;
20 }
21
22 int main ()
23 {
24 PRINT ("main: create coro1");
25 struct coro1 f_coro = f ();
26
27 if (f_coro.handle.done())
28 {
29 PRINT ("main: we should not be 'done' [1]");
30 abort ();
31 }
32 PRINT ("main: resuming [1] initial suspend");
33 f_coro.handle.resume();
34 PRINT ("main: resuming [2] co_await suspend_always_tmpl_awaiter");
35 f_coro.handle.resume();
36
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 int y = f_coro.handle.promise().get_value();
44 if (y != 15)
45 {
46 PRINTF ("main: y is wrong : %d, should be 15\n", y);
47 abort ();
48 }
49 PRINT ("main: done");
50 return 0;
51 }