1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: no-exceptions |
10 | |
11 | // We're testing the diagnosed behaviour here. |
12 | // ADDITIONAL_COMPILE_FLAGS: -Wno-exceptions |
13 | |
14 | #include <cassert> |
15 | #include <cstdlib> |
16 | #include <exception> |
17 | |
18 | #include "test_macros.h" |
19 | |
20 | void func() TEST_NOEXCEPT { |
21 | try { |
22 | throw 1; |
23 | } catch (float) { |
24 | } |
25 | } |
26 | |
27 | void terminate_handler() { |
28 | assert(std::current_exception() != nullptr); |
29 | std::exit(0); |
30 | } |
31 | |
32 | int main(int, char**) { |
33 | std::set_terminate(terminate_handler); |
34 | func(); |
35 | assert(false); |
36 | } |
37 | |