Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/coroutines/torture/func-params-01.C @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 1830386684a0 |
children |
line wrap: on
line source
// { dg-do run } // Simplest test that we correctly handle function params in the body // of the coroutine. No local state, just the parm. #include "../coro.h" // boiler-plate for tests of codegen #include "../coro1-ret-int-yield-int.h" struct coro1 f (int x) noexcept { if (x > 20) { PRINT ("coro1: about to return k"); co_return 6174; } else { PRINT ("coro1: about to return the answer"); co_return 42; } } int main () { PRINT ("main: create coro1"); struct coro1 x = f (32); PRINT ("main: got coro1 - resuming"); if (x.handle.done()) abort(); x.handle.resume(); PRINT ("main: after resume"); int y = x.handle.promise().get_value(); if ( y != 6174 ) abort (); if (!x.handle.done()) { PRINT ("main: apparently not done..."); abort (); } PRINT ("main: returning"); return 0; }