brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 349efcf Raw
52 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++20 %s2 3// expected-no-diagnostics4 5namespace std {6template <typename _Result, typename...>7struct coroutine_traits {8  using promise_type = typename _Result::promise_type;9};10 11template <typename _Promise = void>12struct coroutine_handle;13 14template <>15struct coroutine_handle<void> {16  static coroutine_handle from_address(void *__a) noexcept;17  void resume() const noexcept;18  void destroy() const noexcept;19};20 21template <typename _Promise>22struct coroutine_handle : coroutine_handle<> {};23 24struct suspend_always {25  bool await_ready() const noexcept;26  void await_suspend(coroutine_handle<>) const noexcept;27  void await_resume() const noexcept;28};29} // namespace std30 31class Task {32public:33  struct promise_type {34  public:35    std::suspend_always initial_suspend() noexcept;36    std::suspend_always final_suspend() noexcept;37 38    Task get_return_object() noexcept;39    void unhandled_exception() noexcept;40    void return_value(int value) noexcept;41 42    std::suspend_always yield_value(int value) noexcept;43  };44};45 46Task Foo() noexcept {47  // ICE'd48  co_yield({ int frame = 0; 0; });49  co_await({ int frame = 0; std::suspend_always(); });50  co_return({ int frame = 0; 0; });51}52