Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/coroutines/torture/lambda-06-multi-capture.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 // lambda with parm and local state | |
4 | |
5 #include "../coro.h" | |
6 | |
7 // boiler-plate for tests of codegen | |
8 #include "../coro1-ret-int-yield-int.h" | |
9 | |
10 int main () | |
11 { | |
12 int a_copy = 20; | |
13 int a_ref = 10; | |
14 | |
15 auto f = [&, a_copy]() -> coro1 | |
16 { | |
17 co_return a_ref + a_copy; | |
18 }; | |
19 | |
20 { | |
21 coro1 A = f (); | |
22 A.handle.resume(); | |
23 PRINT ("main: [a_copy = 20, a_ref = 10]"); | |
24 | |
25 int y = A.handle.promise().get_value(); | |
26 if (y != 30) | |
27 { | |
28 PRINTF ("main: A co-ret = %d, should be 30\n", y); | |
29 abort (); | |
30 } | |
31 } | |
32 | |
33 a_copy = 5; | |
34 a_ref = 7; | |
35 | |
36 coro1 B = f (); | |
37 B.handle.resume(); | |
38 PRINT ("main: [a_copy = 5, a_ref = 7]"); | |
39 | |
40 int y = B.handle.promise().get_value(); | |
41 if (y != 27) | |
42 { | |
43 PRINTF ("main: B co-ret = %d, should be 27\n", y); | |
44 abort (); | |
45 } | |
46 | |
47 return 0; | |
48 } |