Debian Codegraph @

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

raw
1 // { dg-additional-options "-fsyntax-only -w" }
2
3 // Diagose missing get_return_object() in the promise type.
4
5 #include "coro.h"
6
7 struct MissingGRO {
8 coro::coroutine_handle<> handle;
9 MissingGRO () : handle (nullptr) {}
10 MissingGRO (coro::coroutine_handle<> handle) : handle (handle) {}
11 struct missing_gro {
12 coro::suspend_never initial_suspend() { return {}; }
13 coro::suspend_never final_suspend() noexcept { return {}; }
14 void return_void () {}
15 void unhandled_exception() { /*std::terminate();*/ };
16 };
17 };
18
19 template<> struct coro::coroutine_traits<MissingGRO> {
20 using promise_type = MissingGRO::missing_gro;
21 };
22
23 MissingGRO
24 bar () // { dg-error {no member named 'get_return_object' in} }
25 {
26 co_return;
27 }
28
29 int main (int ac, char *av[]) {
30 MissingGRO x = bar ();
31 return 0;
32 }