Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/coroutines/torture/lambda-03-auto-parm-1.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 // generic Lambda with auto parm (c++14) | |
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 int main () | |
12 { | |
13 auto f = [](auto y) -> coro1 | |
14 { | |
15 PRINT ("coro1: about to return"); | |
16 auto x = y; | |
17 co_return co_await x + 3; | |
18 }; | |
19 | |
20 PRINT ("main: create coro1"); | |
21 struct coro1 x = f((int)17); | |
22 if (x.handle.done()) | |
23 abort(); | |
24 | |
25 x.handle.resume(); | |
26 PRINT ("main: after resume (initial suspend)"); | |
27 | |
28 x.handle.resume(); | |
29 PRINT ("main: after resume (co_await)"); | |
30 | |
31 /* Now we should have the co_returned value. */ | |
32 int y = x.handle.promise().get_value(); | |
33 if ( y != 20 ) | |
34 { | |
35 PRINTF ("main: wrong result (%d).", y); | |
36 abort (); | |
37 } | |
38 | |
39 if (!x.handle.done()) | |
40 { | |
41 PRINT ("main: apparently not done..."); | |
42 abort (); | |
43 } | |
44 PRINT ("main: returning"); | |
45 return 0; | |
46 } |