| 1 |
// { dg-additional-options "-fsyntax-only" } |
| 2 |
#include <typeinfo> |
| 3 |
#include <coroutine> |
| 4 |
|
| 5 |
struct Task { |
| 6 |
struct promise_type { |
| 7 |
promise_type() = default; |
| 8 |
Task get_return_object() { return {}; } |
| 9 |
std::suspend_never initial_suspend() { return {}; } |
| 10 |
std::suspend_always final_suspend() noexcept { return {}; } |
| 11 |
void unhandled_exception() {} |
| 12 |
void return_void () {} |
| 13 |
std::suspend_never yield_value (int) { return {}; } |
| 14 |
}; |
| 15 |
}; |
| 16 |
|
| 17 |
// We do not permit co_await, co_yield outside a function, and so uses in |
| 18 |
// noexcept or requirements are covered by that. |
| 19 |
Task foo() { |
| 20 |
/* This one will currently fail - see PR68604. */ |
| 21 |
const std::type_info& ti1 = typeid (co_await std::suspend_never{}); // { dg-error {'co_await' cannot be used in an unevaluated context} "" { xfail *-*-* } } |
| 22 |
std::size_t x = sizeof (co_yield (19)); // { dg-error {'co_yield' cannot be used in an unevaluated context} } |
| 23 |
decltype (co_await std::suspend_never{}) A; // { dg-error {'co_await' cannot be used in an unevaluated context} } |
| 24 |
co_return; |
| 25 |
} |