| 1 |
// { dg-additional-options "-fsyntax-only" } |
| 2 |
|
| 3 |
#include <coroutine> |
| 4 |
#include <exception> |
| 5 |
|
| 6 |
struct fire_and_forget { |
| 7 |
}; |
| 8 |
|
| 9 |
template <typename... Args> |
| 10 |
struct std::coroutine_traits<fire_and_forget, Args...> |
| 11 |
{ |
| 12 |
struct promise_type |
| 13 |
{ |
| 14 |
fire_and_forget get_return_object() const noexcept |
| 15 |
{ |
| 16 |
return{}; |
| 17 |
} |
| 18 |
|
| 19 |
void return_void() const noexcept |
| 20 |
{ |
| 21 |
} |
| 22 |
|
| 23 |
suspend_never initial_suspend() const noexcept |
| 24 |
{ |
| 25 |
return{}; |
| 26 |
} |
| 27 |
|
| 28 |
suspend_never final_suspend() const noexcept |
| 29 |
{ |
| 30 |
return{}; |
| 31 |
} |
| 32 |
|
| 33 |
void unhandled_exception() const noexcept |
| 34 |
{ |
| 35 |
std::terminate(); |
| 36 |
} |
| 37 |
}; |
| 38 |
}; |
| 39 |
|
| 40 |
struct foo |
| 41 |
{ |
| 42 |
fire_and_forget bar() |
| 43 |
{ |
| 44 |
co_await std::suspend_always{ }; |
| 45 |
} |
| 46 |
|
| 47 |
private: |
| 48 |
// The line below triggered the error. |
| 49 |
using coroutine_handle = std::coroutine_handle<>; |
| 50 |
}; |
| 51 |
|
| 52 |
int main() |
| 53 |
{ |
| 54 |
foo{}.bar(); |
| 55 |
} |