|
| 1 | +// This test merely verifies that emitting the object file does not cause a |
| 2 | +// crash when the LLVM coroutines passes are run. |
| 3 | +// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o |
| 4 | + |
| 5 | +namespace std::experimental { |
| 6 | +template <typename R, typename... T> struct coroutine_traits { |
| 7 | + using promise_type = typename R::promise_type; |
| 8 | +}; |
| 9 | + |
| 10 | +template <class Promise = void> struct coroutine_handle; |
| 11 | +template <> struct coroutine_handle<void> { |
| 12 | + static coroutine_handle from_address(void *) noexcept; |
| 13 | + coroutine_handle() = default; |
| 14 | + template <class PromiseType> |
| 15 | + coroutine_handle(coroutine_handle<PromiseType>) noexcept; |
| 16 | +}; |
| 17 | +template <class Promise> struct coroutine_handle : coroutine_handle<void> { |
| 18 | + coroutine_handle() = default; |
| 19 | + static coroutine_handle from_address(void *) noexcept; |
| 20 | +}; |
| 21 | +} |
| 22 | + |
| 23 | +struct suspend_always { |
| 24 | + bool await_ready() noexcept; |
| 25 | + void await_suspend(std::experimental::coroutine_handle<>) noexcept; |
| 26 | + void await_resume() noexcept; |
| 27 | +}; |
| 28 | + |
| 29 | +struct task { |
| 30 | + struct promise_type { |
| 31 | + task get_return_object() { return task(); } |
| 32 | + suspend_always initial_suspend() { return {}; } |
| 33 | + suspend_always final_suspend() { return {}; } |
| 34 | + void return_void() {} |
| 35 | + void unhandled_exception() {} |
| 36 | + }; |
| 37 | +}; |
| 38 | + |
| 39 | +struct awaitable { |
| 40 | + task await() { (void)co_await *this; } |
| 41 | + bool await_ready() { return false; } |
| 42 | + bool await_suspend(std::experimental::coroutine_handle<> awaiter) { return false; } |
| 43 | + bool await_resume() { return false; } |
| 44 | +}; |
| 45 | + |
| 46 | +int main() { |
| 47 | + awaitable a; |
| 48 | + a.await(); |
| 49 | +} |
0 commit comments