1*ec117158SChuanqi Xu // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
2a9b3d097SEric Fiselier // RUN:    -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
3a9b3d097SEric Fiselier // RUN:    -fblocks -Wno-unreachable-code -Wno-unused-value
4a9b3d097SEric Fiselier 
5*ec117158SChuanqi Xu // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
6a9b3d097SEric Fiselier // RUN:    -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
7a9b3d097SEric Fiselier // RUN:    -fblocks -Wno-unreachable-code -Wno-unused-value \
8a9b3d097SEric Fiselier // RUN:    -DDISABLE_WARNING -Wno-coroutine-missing-unhandled-exception
9a9fdb346SEric Fiselier 
10a9fdb346SEric Fiselier #if __has_feature(cxx_exceptions)
11a9fdb346SEric Fiselier #error This test requires exceptions be disabled
12a9fdb346SEric Fiselier #endif
13a9fdb346SEric Fiselier 
14a9fdb346SEric Fiselier #include "Inputs/std-coroutine.h"
15a9fdb346SEric Fiselier 
16*ec117158SChuanqi Xu using std::suspend_always;
17*ec117158SChuanqi Xu using std::suspend_never;
18a9fdb346SEric Fiselier 
1929ff638cSGor Nishanov #ifndef DISABLE_WARNING
2029ff638cSGor Nishanov struct promise_void { // expected-note {{defined here}}
2129ff638cSGor Nishanov #else
22a9fdb346SEric Fiselier struct promise_void {
2329ff638cSGor Nishanov #endif
24a9fdb346SEric Fiselier   void get_return_object();
25a9fdb346SEric Fiselier   suspend_always initial_suspend();
26516803dcSXun Li   suspend_always final_suspend() noexcept;
27a9fdb346SEric Fiselier   void return_void();
28a9fdb346SEric Fiselier };
29a9fdb346SEric Fiselier 
30a9fdb346SEric Fiselier template <typename... T>
31*ec117158SChuanqi Xu struct std::coroutine_traits<void, T...> { using promise_type = promise_void; };
32a9fdb346SEric Fiselier 
33a9b3d097SEric Fiselier #ifndef DISABLE_WARNING
test0()34a9fdb346SEric Fiselier void test0() { // expected-warning {{'promise_void' is required to declare the member 'unhandled_exception()' when exceptions are enabled}}
35a9fdb346SEric Fiselier   co_return;
36a9fdb346SEric Fiselier }
37a9b3d097SEric Fiselier #else
test0()38a9b3d097SEric Fiselier void test0() { // expected-no-diagnostics
39a9b3d097SEric Fiselier   co_return;
40a9b3d097SEric Fiselier }
41a9b3d097SEric Fiselier #endif
42