Debian Codegraph @

gcc/testsuite/g++.dg/coroutines/pr95616-0-no-exceptions.C

raw
1 // { dg-additional-options "-fsyntax-only -fno-exceptions" }
2
3 #if __has_include(<coroutine>)
4 #include <coroutine>
5 #else
6 #include <experimental/coroutine>
7 namespace std {
8 using namespace std::experimental;
9 }
10 #endif
11
12 class promise;
13
14 struct finalSuspendAwaiter {
15 int x;
16 finalSuspendAwaiter () : x(0) { }
17 finalSuspendAwaiter (int _x) : x(_x) { }
18 ~finalSuspendAwaiter() noexcept(true) { }
19 bool await_ready() const noexcept(true) { return false; }
20 void await_suspend(std::coroutine_handle<>) const noexcept(true) { }
21 int await_resume() const noexcept(true) { return x; }
22 };
23
24 struct finalSuspendObj {
25 int x;
26 finalSuspendObj () : x(0) { }
27 finalSuspendObj (int _x) : x(_x) { }
28 ~finalSuspendObj () noexcept(true) {}
29
30 finalSuspendAwaiter operator co_await() const & noexcept(true) {
31 return {x};
32 }
33 };
34
35 struct task {
36 struct promise_type {
37 task get_return_object() noexcept { return {}; }
38 std::suspend_never initial_suspend() noexcept { return {}; }
39
40 finalSuspendObj final_suspend() { return {3}; } // NOTE: not declared noexcept
41
42 void return_void() noexcept {}
43 void unhandled_exception() noexcept {}
44 };
45 };
46
47 // OK when exceptions are disabled
48 task f() {
49 co_return;
50 }