blob: 7dbda6f45a9907b0a2b1a4bceb15333957bffa4f [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.
3// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
4
5namespace std::experimental {
6template <typename R, typename... T> struct coroutine_traits {
7 using promise_type = typename R::promise_type;
8};
9
10template <class Promise = void> struct coroutine_handle;
11template <> 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};
17template <class Promise> struct coroutine_handle : coroutine_handle<void> {
18 coroutine_handle() = default;
19 static coroutine_handle from_address(void *) noexcept;
20};
21}
22
23struct suspend_always {
24 bool await_ready() noexcept;
25 void await_suspend(std::experimental::coroutine_handle<>) noexcept;
26 void await_resume() noexcept;
27};
28
29struct 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
39struct 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
46int main() {
47 awaitable a;
48 a.await();
49}