1 // This test merely verifies that emitting the object file does not cause a 2 // crash when the LLVM coroutines passes are run. 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 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 { get_return_objecttask::promise_type33 task get_return_object() { return task(); } initial_suspendtask::promise_type34 suspend_always initial_suspend() { return {}; } final_suspendtask::promise_type35 suspend_always final_suspend() noexcept { return {}; } return_voidtask::promise_type36 void return_void() {} unhandled_exceptiontask::promise_type37 void unhandled_exception() {} 38 }; 39 }; 40 41 struct awaitable { awaitawaitable42 task await() { (void)co_await *this; } await_readyawaitable43 bool await_ready() { return false; } await_suspendawaitable44 bool await_suspend(std::experimental::coroutine_handle<> awaiter) { return false; } await_resumeawaitable45 bool await_resume() { return false; } 46 }; 47 main()48int main() { 49 awaitable a; 50 a.await(); 51 } 52