| 1 |
// { dg-additional-options "-fsyntax-only -w" } |
| 2 |
|
| 3 |
// Diagose missing return_value() in the promise type. |
| 4 |
|
| 5 |
#include "coro.h" |
| 6 |
|
| 7 |
struct MissingRetValue { |
| 8 |
coro::coroutine_handle<> handle; |
| 9 |
MissingRetValue () : handle (nullptr) {} |
| 10 |
MissingRetValue (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 |
MissingRetValue get_return_object() { |
| 15 |
return MissingRetValue (coro::coroutine_handle<missing_retvoid>::from_promise (*this)); |
| 16 |
} |
| 17 |
void unhandled_exception() { /*std::terminate();*/ }; |
| 18 |
}; |
| 19 |
}; |
| 20 |
|
| 21 |
template<> struct coro::coroutine_traits<MissingRetValue> { |
| 22 |
using promise_type = MissingRetValue::missing_retvoid; |
| 23 |
}; |
| 24 |
|
| 25 |
MissingRetValue |
| 26 |
bar () |
| 27 |
{ |
| 28 |
co_return 6174; // { dg-error {no member named 'return_value' 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 |
MissingRetValue x = bar (); |
| 39 |
return 0; |
| 40 |
} |