[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / thread-safety-coro.cpp
blob9d40c3bf492a58e745adf22fbdb88693601baa1a
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++17 -fcoroutines-ts %s
3 // expected-no-diagnostics
5 namespace std {
6 template <typename _Result, typename...>
7 struct coroutine_traits {
8 using promise_type = typename _Result::promise_type;
9 };
11 template <typename _Promise = void>
12 struct coroutine_handle;
14 template <>
15 struct coroutine_handle<void> {
16 static coroutine_handle from_address(void *__a) noexcept;
17 void resume() const noexcept;
18 void destroy() const noexcept;
21 template <typename _Promise>
22 struct coroutine_handle : coroutine_handle<> {};
24 struct suspend_always {
25 bool await_ready() const noexcept;
26 void await_suspend(coroutine_handle<>) const noexcept;
27 void await_resume() const noexcept;
29 } // namespace std
31 class Task {
32 public:
33 struct promise_type {
34 public:
35 std::suspend_always initial_suspend() noexcept;
36 std::suspend_always final_suspend() noexcept;
38 Task get_return_object() noexcept;
39 void unhandled_exception() noexcept;
40 void return_value(int value) noexcept;
42 std::suspend_always yield_value(int value) noexcept;
46 Task Foo() noexcept {
47 // ICE'd
48 co_yield({ int frame = 0; 0; });
49 co_await({ int frame = 0; std::suspend_always(); });
50 co_return({ int frame = 0; 0; });