Debian Codegraph @

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

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