Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/pr96749-2.C

raw
1 // { dg-additional-options "-Wall" }
2
3 #include <coroutine>
4
5 #if 1
6 // with a struct, GCC emits "statement has no effect"
7 struct S {};
8 #else
9 // no warning with built-in types
10 using S = int;
11 #endif
12
13 S Func1(int);
14
15 struct C {
16 auto operator co_await() {
17 struct Awaitable final {
18 bool await_ready() const { return true; }
19 std::coroutine_handle<> await_suspend(std::coroutine_handle<>) { return {}; }
20 int await_resume() { return 42; }
21 };
22 return Awaitable{};
23 }
24 };
25
26 struct Task {
27 struct promise_type {
28 auto initial_suspend() { return std::suspend_always{}; }
29 auto final_suspend() noexcept { return std::suspend_always{}; }
30 Task get_return_object() ;
31 void unhandled_exception() {}
32 };
33 };
34
35 Task Func2() {
36 Func1(co_await C());
37 }