comparison gcc/testsuite/g++.dg/coroutines/coro-missing-ret-value.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
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() { 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 int main (int ac, char *av[]) {
32 MissingRetValue x = bar ();
33 return 0;
34 }