blob: 8728c1511122b8b0ec7473f88592c1f0a195f86d [file] [log] [blame]
Brian Gesiakf8d68362019-08-13 12:02:25 +00001// This test merely verifies that emitting the object file does not cause a
2// crash when the LLVM coroutines passes are run.
Leonard Chanb0a75442019-08-20 20:55:36 +00003// 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 Gesiakf8d68362019-08-13 12:02:25 +00006
7namespace std::experimental {
8template <typename R, typename... T> struct coroutine_traits {
9 using promise_type = typename R::promise_type;
10};
11
12template <class Promise = void> struct coroutine_handle;
13template <> 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};
19template <class Promise> struct coroutine_handle : coroutine_handle<void> {
20 coroutine_handle() = default;
21 static coroutine_handle from_address(void *) noexcept;
22};
23}
24
25struct suspend_always {
26 bool await_ready() noexcept;
27 void await_suspend(std::experimental::coroutine_handle<>) noexcept;
28 void await_resume() noexcept;
29};
30
31struct 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
41struct 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
48int main() {
49 awaitable a;
50 a.await();
51}