[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / coroutine-unhandled_exception-warning.cpp
blob5ea1e5d6724422eb0c31fdf99092ed884cf8adb1
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
2 // RUN: -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
3 // RUN: -fblocks -Wno-unreachable-code -Wno-unused-value
5 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
6 // RUN: -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
7 // RUN: -fblocks -Wno-unreachable-code -Wno-unused-value \
8 // RUN: -DDISABLE_WARNING -Wno-coroutine-missing-unhandled-exception
10 #if __has_feature(cxx_exceptions)
11 #error This test requires exceptions be disabled
12 #endif
14 #include "Inputs/std-coroutine.h"
16 using std::suspend_always;
17 using std::suspend_never;
19 #ifndef DISABLE_WARNING
20 struct promise_void { // expected-note {{defined here}}
21 #else
22 struct promise_void {
23 #endif
24 void get_return_object();
25 suspend_always initial_suspend();
26 suspend_always final_suspend() noexcept;
27 void return_void();
30 template <typename... T>
31 struct std::coroutine_traits<void, T...> { using promise_type = promise_void; };
33 #ifndef DISABLE_WARNING
34 void test0() { // expected-warning {{'promise_void' is required to declare the member 'unhandled_exception()' when exceptions are enabled}}
35 co_return;
37 #else
38 void test0() { // expected-no-diagnostics
39 co_return;
41 #endif