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 | // test get_new_handler |
10 | |
11 | // FIXME: When libc++ is linked against vcruntime (i.e. the default config in |
12 | // MSVC mode), the declarations of std::set_new_handler and std::get_new_handler |
13 | // are provided by vcruntime/UCRT's new.h. However, that header actually only |
14 | // declares set_new_handler - it's missing a declaration of get_new_handler. |
15 | |
16 | // XFAIL: msvc && stdlib=libc++ |
17 | |
18 | #include <new> |
19 | #include <cassert> |
20 | |
21 | #include "test_macros.h" |
22 | |
23 | void f1() {} |
24 | void f2() {} |
25 | |
26 | int main(int, char**) |
27 | { |
28 | assert(std::get_new_handler() == 0); |
29 | std::set_new_handler(f1); |
30 | assert(std::get_new_handler() == f1); |
31 | std::set_new_handler(f2); |
32 | assert(std::get_new_handler() == f2); |
33 | |
34 | return 0; |
35 | } |
36 | |