1 //===----------------------------------------------------------------------===//
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
7 //===------------------------------------------------------------------------===//
18 #include "test_macros.h"
21 virtual void foo() {};
24 class Derived
: public Base
{};
26 std::string
test_bad_typeid(Derived
*p
) {
27 return typeid(*p
).name();
30 void my_terminate() { exit(0); }
34 // swap-out the terminate handler
35 void (*default_handler
)() = std::get_terminate();
36 std::set_terminate(my_terminate
);
38 #ifndef TEST_HAS_NO_EXCEPTIONS
41 test_bad_typeid(nullptr);
43 #ifndef TEST_HAS_NO_EXCEPTIONS
44 } catch (std::bad_typeid
const&) {
52 // failure, restore the default terminate handler and fire
53 std::set_terminate(default_handler
);