Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/co-yield-syntax-08-needs-expr.C

raw
1 // { dg-additional-options "-fsyntax-only -w" }
2
3 // Check syntax for missing expr in a coroutine context.
4
5 #include "coro.h"
6
7 struct DummyYield {
8 coro::coroutine_handle<> handle;
9 DummyYield () : handle (nullptr) {}
10 DummyYield (coro::coroutine_handle<> handle) : handle (handle) {}
11 struct dummy_yield {
12 coro::suspend_never initial_suspend() { return {}; }
13 coro::suspend_never final_suspend() noexcept { return {}; }
14 DummyYield get_return_object() {
15 return DummyYield (coro::coroutine_handle<dummy_yield>::from_promise (*this));
16 }
17 void yield_value (int v) {}
18 void return_value (int v) {}
19 void unhandled_exception() { /*std::terminate();*/ };
20 };
21 };
22
23 template<> struct coro::coroutine_traits<DummyYield> {
24 using promise_type = DummyYield::dummy_yield;
25 };
26
27 DummyYield
28 bar ()
29 {
30 co_yield; // { dg-error {expected primary-expression before} }
31 co_return 0;
32 }
33
34 int main (int ac, char *av[]) {
35 DummyYield x = bar ();
36 return 0;
37 }