1 //  { dg-additional-options "-Wall" }
2 
3 #include <coroutine>
4 
5 template <typename _Tp> struct promise;
6 template <typename _Tp> struct task {
7 	using promise_type = promise<_Tp>;
await_readytask8 	bool await_ready() noexcept { return false; }
await_suspendtask9 	void await_suspend(std::coroutine_handle<> awaiter) noexcept { m_a = awaiter; }
await_resumetask10 	auto await_resume() { return _Tp(); }
11 	std::coroutine_handle<> m_a;
12 };
13 
14 template <typename _Tp> struct promise {
get_return_objectpromise15 	auto get_return_object() noexcept { return task<_Tp>(); }
initial_suspendpromise16 	auto initial_suspend() noexcept { return std::suspend_always(); }
final_suspendpromise17 	auto final_suspend() noexcept { return std::suspend_always(); }
return_valuepromise18 	void return_value(_Tp value) noexcept { m_v = value; }
unhandled_exceptionpromise19 	void unhandled_exception() noexcept {}
20 	_Tp m_v;
21 };
22 
test_coro(void)23 task<int> test_coro(void) {
24 	int r = 0;
25 #if 1
26 	// this code causes the unexpected warning below
27 	r += co_await task<int>();
28 #else
29 	// this code causes no warning
30 	auto b = co_await task<int>();
31 	r += b;
32 #endif
33 	co_return r;
34 	// test1.cpp: In function ‘task<int> test_coro(int)’:
35 	// test1.cpp:36:1: warning: statement has no effect [-Wunused-value]
36 	//   36 | }
37 	//      | ^
38 }
39 
main(void)40 int main(void) {
41 	return 0;
42 }
43