Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/pr101133.C

raw
1 // { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } }
2 #include <coroutine>
3 #include <string>
4
5 template<typename T>
6 struct Awaiter
7 {
8 bool await_ready() const { return false; }
9 void await_suspend(std::coroutine_handle<>) const {}
10 T await_resume() const { return T{}; }
11 };
12
13 struct ReturnObject
14 {
15 struct promise_type
16 {
17 ReturnObject get_return_object() { return {}; }
18 std::suspend_never initial_suspend() noexcept { return {}; }
19 std::suspend_never final_suspend() noexcept { return {}; }
20 void return_void() {}
21 void unhandled_exception() {}
22 };
23 };
24
25 ReturnObject f()
26 {
27 auto a1 = Awaiter<int>{};
28 auto a2 = Awaiter<std::string>{};
29
30 [[maybe_unused]] auto v1 = co_await a1; // ok
31 [[maybe_unused]] std::string v2 = co_await a2; // error
32 }