Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/coroutines/torture/local-var-01-single.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 // Simplest local var | |
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 (int x) noexcept | |
12 { | |
13 int answer = x + 6132; | |
14 PRINTF ("coro1: about to return %d\n", answer); | |
15 co_return answer; | |
16 } | |
17 | |
18 int main () | |
19 { | |
20 PRINT ("main: create coro1"); | |
21 struct coro1 x = f (42); | |
22 PRINT ("main: got coro1 - resuming"); | |
23 if (x.handle.done()) | |
24 abort(); | |
25 x.handle.resume(); | |
26 PRINT ("main: after resume"); | |
27 int y = x.handle.promise().get_value(); | |
28 if ( y != 6174 ) | |
29 abort (); | |
30 if (!x.handle.done()) | |
31 { | |
32 PRINT ("main: apparently not done..."); | |
33 abort (); | |
34 } | |
35 PRINT ("main: returning"); | |
36 return 0; | |
37 } |