brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · dfa50cb Raw
58 lines · cpp
1// RUN: %clang_cc1 -std=c++2b %s -fsyntax-only -verify2 3#include "Inputs/std-coroutine.h"4 5struct S;6template <typename T>7class coro_test {8public:9    struct promise_type;10    using handle = std::coroutine_handle<promise_type>;11	struct promise_type {12        promise_type(const promise_type&) = delete; // #copy-ctr13        promise_type(T);  // #candidate14        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();19 20 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}}24        }25 26    };27private:28	handle h;29};30 31 32template <typename Ret, typename... P>33struct 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}}36};37 38 39struct S {40 41    coro_test<S&> ok(this S&, int) {42        co_return; // expected-note {{in instantiation}}43    }44 45    coro_test<const S&> ok2(this const S&) { // expected-note {{in instantiation}}46        co_return;47    }48 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-existing52                                       // 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;55    }56 57};58