| 1 |
// { dg-do run } |
| 2 |
// { dg-skip-if "requires hosted libstdc++ for cstdlib abort" { ! hostedlib } } |
| 3 |
|
| 4 |
#include "coro.h" |
| 5 |
|
| 6 |
struct simple { |
| 7 |
static inline int alive = 0; |
| 8 |
simple() { ++alive; } |
| 9 |
simple(simple&&) { ++alive; } |
| 10 |
~simple() { --alive; } |
| 11 |
|
| 12 |
struct promise_type { |
| 13 |
simple get_return_object() { return simple{}; } |
| 14 |
void return_void() {} |
| 15 |
void unhandled_exception() {} |
| 16 |
auto initial_suspend() noexcept { return coro::suspend_never{}; } |
| 17 |
auto final_suspend() noexcept { return coro::suspend_never{}; } |
| 18 |
}; |
| 19 |
}; |
| 20 |
|
| 21 |
simple |
| 22 |
f() |
| 23 |
{ |
| 24 |
co_return; |
| 25 |
} |
| 26 |
|
| 27 |
int main() { |
| 28 |
{ |
| 29 |
f(); |
| 30 |
} |
| 31 |
|
| 32 |
if (simple::alive != 0) |
| 33 |
{ |
| 34 |
PRINTF ("something wrong with dtors: %d\n", simple::alive); |
| 35 |
abort (); |
| 36 |
} |
| 37 |
return 0; |
| 38 |
} |