================ @@ -291,6 +294,38 @@ void mixed_coreturn_template2(bool b, T) { return; // expected-error {{not allowed in coroutine}} } +struct promise_handle; + +struct Handle : std::coroutine_handle<promise_handle> { // expected-note 2{{candidate constructor (the implicit copy constructor) not viable}} + // expected-note@-1 2{{candidate constructor (the implicit move constructor) not viable}} + using promise_type = promise_handle; +}; + +struct promise_handle { + Handle get_return_object() noexcept { + { return Handle(std::coroutine_handle<Handle::promise_type>::from_promise(*this)); } + } + suspend_never initial_suspend() const noexcept { return {}; } + suspend_never final_suspend() const noexcept { return {}; } + void return_void() const noexcept {} + void unhandled_exception() const noexcept {} +}; + +Handle mixed_return_value() { + co_await a; // expected-note {{function is a coroutine due to use of 'co_await' here}} + return 0; // expected-error {{return statement not allowed in coroutine}} + // expected-error@-1 {{no viable conversion from returned value of type}} ---------------- ilya-biryukov wrote:
the `-verify` and `expected-error` does not actually let us check the order in which the errors are reported. Could we add another test file that would do something like: ``` // RUN: %clang_cc1 -fsyntax-only %s 2>& 1 | FileCheck // The error about a function not being a coroutine is usually more relevant than the conversion error. // Check that we show it first. <test code here> // CHECK-NOT: cannot convert // CHECK: return statement not allowed in coroutine // CHECK: cannot convert ``` it does not have to be detailed, just to make sure we actually managed to keep the errors in that order https://github.com/llvm/llvm-project/pull/100985 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits