1 // This tests that the symmetric transfer at the final suspend point could happen successfully.
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -O2 -emit-llvm %s -o - | FileCheck %s
4 #include "Inputs/coroutine.h"
9 bool await_ready() const noexcept
{ return false; }
10 template <typename PromiseType
>
11 std::coroutine_handle
<> await_suspend(std::coroutine_handle
<PromiseType
> h
) noexcept
{
12 return h
.promise().continuation
;
14 void await_resume() noexcept
{}
16 Task
get_return_object() noexcept
{
17 return std::coroutine_handle
<promise_type
>::from_promise(*this);
19 std::suspend_always
initial_suspend() noexcept
{ return {}; }
20 FinalAwaiter
final_suspend() noexcept
{ return {}; }
21 void unhandled_exception() noexcept
{}
22 void return_value(int x
) noexcept
{
25 std::coroutine_handle
<> continuation
;
29 Task(std::coroutine_handle
<promise_type
> handle
) : handle(handle
) {}
36 std::coroutine_handle
<promise_type
> handle
;
37 Awaiter(std::coroutine_handle
<promise_type
> handle
) : handle(handle
) {}
38 bool await_ready() const noexcept
{ return false; }
39 std::coroutine_handle
<void> await_suspend(std::coroutine_handle
<void> continuation
) noexcept
{
40 handle
.promise().continuation
= continuation
;
43 int await_resume() noexcept
{
44 int ret
= handle
.promise()._value
;
50 auto operator co_await() {
51 auto handle_
= handle
;
53 return Awaiter(handle_
);
57 std::coroutine_handle
<promise_type
> handle
;
64 // CHECK-LABEL: define{{.*}} void @_Z5task0v.resume
65 // This checks we are still in the scope of the current function.
67 // CHECK: musttail call fastcc void
68 // CHECK-NEXT: ret void