Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / cxx2b-deducing-this-coro.cpp
blobdfa50cb75acfabb6d5f1fa56a1365be25f1870b7
1 // RUN: %clang_cc1 -std=c++2b %s -fsyntax-only -verify
3 #include "Inputs/std-coroutine.h"
5 struct S;
6 template <typename T>
7 class coro_test {
8 public:
9 struct promise_type;
10 using handle = std::coroutine_handle<promise_type>;
11 struct promise_type {
12 promise_type(const promise_type&) = delete; // #copy-ctr
13 promise_type(T); // #candidate
14 coro_test get_return_object();
15 std::suspend_never initial_suspend();
16 std::suspend_never final_suspend() noexcept;
17 void return_void();
18 void unhandled_exception();
21 template<typename Arg, typename... Args>
22 void* operator new(decltype(0zu) sz, Arg&&, Args&... args) {
23 static_assert(!__is_same(__decay(Arg), S), "Ok"); // expected-error 2{{Ok}}
27 private:
28 handle h;
32 template <typename Ret, typename... P>
33 struct std::coroutine_traits<coro_test<S&>, Ret, P...> {
34 using promise_type = coro_test<S&>::promise_type;
35 static_assert(!__is_same(Ret, S&), "Ok"); // expected-error{{static assertion failed due to requirement '!__is_same(S &, S &)': Ok}}
39 struct S {
41 coro_test<S&> ok(this S&, int) {
42 co_return; // expected-note {{in instantiation}}
45 coro_test<const S&> ok2(this const S&) { // expected-note {{in instantiation}}
46 co_return;
49 coro_test<int> ko(this const S&) { // expected-error {{no matching constructor for initialization of 'std::coroutine_traits<coro_test<int>, const S &>::promise_type'}} \
50 // expected-note {{in instantiation}} \
51 // FIXME: the message below is unhelpful but this is pre-existing
52 // expected-note@#candidate {{candidate constructor not viable: requires 1 argument, but 0 were provided}} \
53 // expected-note@#copy-ctr {{candidate constructor not viable}}
54 co_return;