Debian Codegraph @

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

raw
1 // { dg-additional-options "-fsyntax-only" }
2
3 #include <coroutine>
4
5 struct awaitable {
6 constexpr bool await_ready() {
7 return true;
8 }
9 void await_suspend(std::coroutine_handle<void>) {
10
11 }
12 constexpr int await_resume() {
13 return 42;
14 }
15 };
16
17 struct super_simple_coroutine {
18 struct promise_type {
19 constexpr auto initial_suspend() {
20 return std::suspend_never();
21 }
22 constexpr auto final_suspend() const noexcept {
23 return std::suspend_never();
24 }
25 constexpr void unhandled_exception() {
26 // do nothing
27 }
28 constexpr auto get_return_object() {
29 return super_simple_coroutine{};
30 }
31 constexpr void return_void() {
32 }
33 };
34 };
35
36 auto fib (float f) -> super_simple_coroutine {
37 // if `co_await` is part of BodyStatement of a function
38 // it makes it coroutine
39 constexpr int x = co_await awaitable{}; // { dg-error {'co_await awaitable..' is not a constant expression} }
40 }