Brian Gesiak | f8d6836 | 2019-08-13 12:02:25 +0000 | [diff] [blame] | 1 | // This test merely verifies that emitting the object file does not cause a |
| 2 | // crash when the LLVM coroutines passes are run. |
Leonard Chan | b0a7544 | 2019-08-20 20:55:36 +0000 | [diff] [blame] | 3 | // PR42867: Disable this test for the new PM since the passes that lower the |
| 4 | // llvm.coro.* intrinsics have not yet been ported. |
| 5 | // RUN: %clang_cc1 -fno-experimental-new-pass-manager -emit-obj -std=c++2a -fsanitize=null %s -o %t.o |
Brian Gesiak | f8d6836 | 2019-08-13 12:02:25 +0000 | [diff] [blame] | 6 | |
| 7 | namespace std::experimental { |
| 8 | template <typename R, typename... T> struct coroutine_traits { |
| 9 | using promise_type = typename R::promise_type; |
| 10 | }; |
| 11 | |
| 12 | template <class Promise = void> struct coroutine_handle; |
| 13 | template <> struct coroutine_handle<void> { |
| 14 | static coroutine_handle from_address(void *) noexcept; |
| 15 | coroutine_handle() = default; |
| 16 | template <class PromiseType> |
| 17 | coroutine_handle(coroutine_handle<PromiseType>) noexcept; |
| 18 | }; |
| 19 | template <class Promise> struct coroutine_handle : coroutine_handle<void> { |
| 20 | coroutine_handle() = default; |
| 21 | static coroutine_handle from_address(void *) noexcept; |
| 22 | }; |
| 23 | } |
| 24 | |
| 25 | struct suspend_always { |
| 26 | bool await_ready() noexcept; |
| 27 | void await_suspend(std::experimental::coroutine_handle<>) noexcept; |
| 28 | void await_resume() noexcept; |
| 29 | }; |
| 30 | |
| 31 | struct task { |
| 32 | struct promise_type { |
| 33 | task get_return_object() { return task(); } |
| 34 | suspend_always initial_suspend() { return {}; } |
| 35 | suspend_always final_suspend() { return {}; } |
| 36 | void return_void() {} |
| 37 | void unhandled_exception() {} |
| 38 | }; |
| 39 | }; |
| 40 | |
| 41 | struct awaitable { |
| 42 | task await() { (void)co_await *this; } |
| 43 | bool await_ready() { return false; } |
| 44 | bool await_suspend(std::experimental::coroutine_handle<> awaiter) { return false; } |
| 45 | bool await_resume() { return false; } |
| 46 | }; |
| 47 | |
| 48 | int main() { |
| 49 | awaitable a; |
| 50 | a.await(); |
| 51 | } |