1 //===----------------------- cxa_bad_typeid.pass.cpp ------------------------===//
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 //===------------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03
20 virtual void foo() {};
23 class Derived
: public Base
{};
25 std::string
test_bad_typeid(Derived
*p
) {
26 return typeid(*p
).name();
29 void my_terminate() { std::cout
<< "A" << std::endl
; exit(0); }
33 // swap-out the terminate handler
34 void (*default_handler
)() = std::get_terminate();
35 std::set_terminate(my_terminate
);
37 #ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
40 test_bad_typeid(nullptr);
42 #ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
43 } catch (std::bad_typeid
) {
51 // failure, restore the default terminate handler and fire
52 std::set_terminate(default_handler
);