| 1 |
// RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s |
| 2 |
|
| 3 |
#include "Inputs/coroutine.h" |
| 4 |
|
| 5 |
struct coro1 { |
| 6 |
struct promise_type { |
| 7 |
coro1 get_return_object(); |
| 8 |
std::suspend_never initial_suspend(); |
| 9 |
std::suspend_never final_suspend() noexcept; |
| 10 |
void return_void(); |
| 11 |
void unhandled_exception() noexcept; |
| 12 |
}; |
| 13 |
}; |
| 14 |
|
| 15 |
coro1 f() { |
| 16 |
co_await std::suspend_never{}; |
| 17 |
} |
| 18 |
|
| 19 |
// CHECK-LABEL: define{{.*}} void @_Z1fv( |
| 20 |
// CHECK: call void @_ZNSt13suspend_never12await_resumeEv(ptr |
| 21 |
// CHECK: call void @_ZN5coro112promise_type11return_voidEv(ptr {{[^,]*}} %__promise) |
| 22 |
|
| 23 |
struct A { |
| 24 |
A(); |
| 25 |
~A(); |
| 26 |
}; |
| 27 |
|
| 28 |
coro1 f2() { |
| 29 |
co_return (void) A{}; |
| 30 |
} |
| 31 |
|
| 32 |
// CHECK-LABEL: define{{.*}} void @_Z2f2v( |
| 33 |
// CHECK: call void @_ZN1AC1Ev(ptr {{[^,]*}} %[[AVar:.*]]) |
| 34 |
// CHECK-NEXT: call void @_ZN1AD1Ev(ptr {{[^,]*}} %[[AVar]]) |
| 35 |
// CHECK-NEXT: call void @_ZN5coro112promise_type11return_voidEv(ptr |
| 36 |
|
| 37 |
struct coro2 { |
| 38 |
struct promise_type { |
| 39 |
coro2 get_return_object(); |
| 40 |
std::suspend_never initial_suspend(); |
| 41 |
std::suspend_never final_suspend() noexcept; |
| 42 |
void return_value(int); |
| 43 |
void unhandled_exception() noexcept; |
| 44 |
}; |
| 45 |
}; |
| 46 |
|
| 47 |
coro2 g() { |
| 48 |
co_return 42; |
| 49 |
} |
| 50 |
|
| 51 |
// CHECK-LABEL: define{{.*}} void @_Z1gv( |
| 52 |
// CHECK: call void @_ZNSt13suspend_never12await_resumeEv(ptr |
| 53 |
// CHECK: call void @_ZN5coro212promise_type12return_valueEi(ptr {{[^,]*}} %__promise, i32 noundef 42) |