Skip to content

Commit e11b488

Browse files
add test case for the previously crashing case
1 parent e7d1ae0 commit e11b488

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %clang_cc1 -std=c++20 -triple=x86_64-- -emit-llvm -fcxx-exceptions \
2+
// RUN: -disable-llvm-passes %s -o - | FileCheck %s
3+
4+
#include "Inputs/coroutine.h"
5+
6+
struct NontrivialType {
7+
~NontrivialType() {}
8+
};
9+
10+
struct Task {
11+
struct promise_type;
12+
using handle_type = std::coroutine_handle<promise_type>;
13+
14+
struct initial_suspend_awaiter {
15+
bool await_ready() {
16+
return false;
17+
}
18+
19+
void await_suspend(handle_type h) {}
20+
21+
NontrivialType await_resume() { return {}; }
22+
};
23+
24+
struct promise_type {
25+
void return_void() {}
26+
void unhandled_exception() {}
27+
initial_suspend_awaiter initial_suspend() { return {}; }
28+
std::suspend_never final_suspend() noexcept { return {}; }
29+
Task get_return_object() {
30+
return Task{handle_type::from_promise(*this)};
31+
}
32+
};
33+
34+
handle_type handler;
35+
};
36+
37+
Task coro_create() {
38+
co_return;
39+
}
40+
41+
// CHECK-LABEL: define{{.*}} ptr @_Z11coro_createv(
42+
// CHECK: init.ready:
43+
// CHECK-NEXT: store i1 true, ptr {{.*}}
44+
// CHECK-NEXT: call void @_ZN4Task23initial_suspend_awaiter12await_resumeEv(
45+
// CHECK-NEXT: call void @_ZN14NontrivialTypeD1Ev(
46+
// CHECK-NEXT: store i1 false, ptr {{.*}}

0 commit comments

Comments
 (0)