Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/coroutines/torture/co-yield-05-co-aw.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // { dg-do run } | |
2 | |
3 // Check co_return co_await | |
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 () noexcept | |
12 { | |
13 PRINT ("f: about to yield"); | |
14 co_yield co_await coro1::suspend_always_intprt(42); | |
15 | |
16 PRINT ("f: about to return 6174"); | |
17 co_return 6174; | |
18 } | |
19 | |
20 int main () | |
21 { | |
22 PRINT ("main: create coro1"); | |
23 struct coro1 x = f (); | |
24 if (x.handle.done()) | |
25 abort(); | |
26 | |
27 PRINT ("main: resuming (initial suspend)"); | |
28 x.handle.resume(); | |
29 PRINT ("main: resuming (await intprt)"); | |
30 x.handle.resume(); | |
31 | |
32 PRINT ("main: after resume (2)"); | |
33 int y = x.handle.promise().get_value(); | |
34 if ( y != 42 ) | |
35 abort (); | |
36 PRINT ("main: apparently got 42"); | |
37 | |
38 PRINT ("main: got coro1 - resuming (co_yield)"); | |
39 if (x.handle.done()) | |
40 abort(); | |
41 x.handle.resume(); | |
42 | |
43 PRINT ("main: after resume (co_yield)"); | |
44 y = x.handle.promise().get_value(); | |
45 if ( y != 6174 ) | |
46 abort (); | |
47 PRINT ("main: apparently got 6174"); | |
48 if (!x.handle.done()) | |
49 { | |
50 PRINT ("main: apparently not done..."); | |
51 abort (); | |
52 } | |
53 PRINT ("main: returning"); | |
54 return 0; | |
55 } |