Debian Codegraph @

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

raw
1 // PR c++/125376
2 // { dg-do run { target c++26 } }
3
4 #include <coroutine>
5
6 struct task {
7 struct promise_type {
8 task get_return_object () noexcept { return {}; }
9 std::suspend_never initial_suspend () noexcept { return {}; }
10 std::suspend_never final_suspend () noexcept { return {}; }
11 void return_void () noexcept {}
12 void unhandled_exception () {}
13 };
14 };
15
16 struct A {
17 unsigned value = 42;
18 A () {}
19 ~A () { if (value != 42) __builtin_abort (); }
20 };
21
22 struct B {
23 unsigned value = 43;
24 B () {}
25 ~B () { if (value != 43) __builtin_abort (); }
26 };
27
28 task
29 foo ()
30 {
31 auto _ = A {};
32 auto _ = B {};
33 co_return;
34 }
35
36 int
37 main ()
38 {
39 foo ();
40 }