Debian Codegraph @

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

raw
1 // { dg-do run }
2 // { dg-output {^} }
3 // { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} }
4 // { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} }
5 // { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} }
6 // { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} }
7 // { dg-output {ReturnObject bar\(int, char, bool\)(\n|\r\n|\r)} }
8 // { dg-output {$} }
9 // https://gcc.gnu.org/PR110855
10 #include <coroutine>
11 #include <source_location>
12
13 struct ReturnObject {
14 struct promise_type {
15 auto
16 initial_suspend(const std::source_location location =
17 std::source_location::current()) {
18 __builtin_puts (location.function_name ());
19 return std::suspend_never{};
20 }
21 auto
22 final_suspend(const std::source_location location =
23 std::source_location::current()) noexcept {
24 __builtin_puts (location.function_name ());
25 return std::suspend_never{};
26 }
27 auto
28 get_return_object(const std::source_location location =
29 std::source_location::current()) {
30 __builtin_puts (location.function_name ());
31 return ReturnObject{std::coroutine_handle<promise_type>::from_promise(*this)};
32 }
33 auto
34 unhandled_exception() { }
35 auto return_void(const std::source_location location =
36 std::source_location::current()) {
37 __builtin_puts (location.function_name ());
38 }
39 };
40 std::coroutine_handle<> handle;
41 };
42
43 struct awaitable : std::suspend_never
44 {
45 void await_resume(const std::source_location location =
46 std::source_location::current())
47 {
48 __builtin_puts (location.function_name ());
49 }
50 };
51
52 ReturnObject
53 bar(int, char, bool) {
54 co_await awaitable{};
55 co_return;
56 }
57
58 int
59 main() {
60 bar(1, 'a', false);
61 }