Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / coroutine-alloc-3.cpp
blob629ac88a3df8e1eb834d6aef8a93e3d7b1143970
1 // Tests that we'll emit the proper diagnostic message if we failed to find `::operator new(size_­t, nothrow_­t)`.
2 // RUN: %clang_cc1 %s -std=c++20 %s -fsyntax-only -verify
4 namespace std {
5 template <typename... T>
6 struct coroutine_traits;
8 template <class Promise = void>
9 struct coroutine_handle {
10 coroutine_handle() = default;
11 static coroutine_handle from_address(void *) noexcept { return {}; }
14 template <>
15 struct coroutine_handle<void> {
16 static coroutine_handle from_address(void *) { return {}; }
17 coroutine_handle() = default;
18 template <class PromiseType>
19 coroutine_handle(coroutine_handle<PromiseType>) noexcept {}
22 struct suspend_always {
23 bool await_ready() noexcept { return false; }
24 void await_suspend(std::coroutine_handle<>) noexcept {}
25 void await_resume() noexcept {}
28 struct nothrow_t {};
29 constexpr nothrow_t nothrow = {};
31 } // end namespace std
33 using SizeT = decltype(sizeof(int));
35 struct promise_on_alloc_failure_tag {};
37 template <>
38 struct std::coroutine_traits<int, promise_on_alloc_failure_tag> {
39 struct promise_type {
40 int get_return_object() { return 0; }
41 std::suspend_always initial_suspend() { return {}; }
42 std::suspend_always final_suspend() noexcept { return {}; }
43 void return_void() {}
44 void unhandled_exception() {}
45 static int get_return_object_on_allocation_failure() { return -1; }
49 extern "C" int f(promise_on_alloc_failure_tag) { // expected-error 1+{{unable to find '::operator new(size_t, nothrow_t)' for 'f'}}
50 co_return;