Add comment for SelectionDAGBuilder::SL field.
[llvm-project.git] / libcxxabi / test / cxa_bad_typeid.pass.cpp
blob62a3c27b1fc545dd0cf38676f9b005d2f12c041a
1 //===----------------------- cxa_bad_typeid.pass.cpp ------------------------===//
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 //===------------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03
11 #include <cxxabi.h>
12 #include <cassert>
13 #include <stdlib.h>
14 #include <exception>
15 #include <typeinfo>
16 #include <string>
17 #include <iostream>
19 class Base {
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); }
31 int main ()
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
38 try {
39 #endif
40 test_bad_typeid(nullptr);
41 assert(false);
42 #ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
43 } catch (std::bad_typeid) {
44 // success
45 return 0;
46 } catch (...) {
47 assert(false);
49 #endif
51 // failure, restore the default terminate handler and fire
52 std::set_terminate(default_handler);
53 std::terminate();