Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/coro-missing-promise-yield.C

raw
1 // { dg-additional-options "-fsyntax-only -w" }
2 #include "coro.h"
3
4 struct MissingPromiseYield {
5 coro::coroutine_handle<> handle;
6 MissingPromiseYield () : handle (nullptr) {}
7 MissingPromiseYield (coro::coroutine_handle<> handle) : handle (handle) {}
8 struct missing_yield {
9 coro::suspend_never initial_suspend() { return {}; }
10 coro::suspend_never final_suspend() noexcept { return {}; }
11 MissingPromiseYield get_return_object() {
12 return MissingPromiseYield (coro::coroutine_handle<missing_yield>::from_promise (*this));
13 }
14 void return_value (int v) {}
15 void unhandled_exception() { /*std::terminate();*/ };
16 };
17 };
18
19 template<> struct coro::coroutine_traits<MissingPromiseYield> {
20 using promise_type = MissingPromiseYield::missing_yield;
21 };
22
23 MissingPromiseYield
24 bar ()
25 {
26 co_yield 22; // { dg-error {no member named 'yield_value' in} }
27 co_return 0;
28 }
29
30 // check we have not messed up continuation of the compilation.
31 template <class... Args>
32 struct void_t_imp {
33 using type = void;
34 };
35
36 int main (int ac, char *av[]) {
37 MissingPromiseYield x = bar ();
38 return 0;
39 }