brintos

brintos / llvm-project-archived public Read only

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