teak-llvm/clang/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
Eric Fiselier a9fdb346db [coroutines] Implement unhandled_exception changes.
Summary:
This patch adopts the recent changes that renamed `set_exception(exception_pointer)` to `unhandled_exception()`. 

Additionally `unhandled_exception()` is now required, and so an error is emitted when exceptions are enabled but the promise type does not provide the member.
When exceptions are disabled a warning is emitted instead of an error, The warning notes that the `unhandled_exception()` function is required when exceptions are enabled.

Reviewers: rsmith, GorNishanov, aaron.ballman, majnemer

Reviewed By: GorNishanov

Subscribers: mehdi_amini, cfe-commits

Differential Revision: https://reviews.llvm.org/D30859

llvm-svn: 298565
2017-03-23 00:33:33 +00:00

25 lines
824 B
C++

// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
#if __has_feature(cxx_exceptions)
#error This test requires exceptions be disabled
#endif
#include "Inputs/std-coroutine.h"
using std::experimental::suspend_always;
using std::experimental::suspend_never;
struct promise_void {
void get_return_object();
suspend_always initial_suspend();
suspend_always final_suspend();
void return_void();
};
template <typename... T>
struct std::experimental::coroutine_traits<void, T...> { using promise_type = promise_void; };
void test0() { // expected-warning {{'promise_void' is required to declare the member 'unhandled_exception()' when exceptions are enabled}}
co_return;
}