1 //===----------------------- noexception2.pass.cpp ------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03
11 // REQUIRES: libcxxabi-no-exceptions
12 
13 #include <cxxabi.h>
14 #include <exception>
15 #include <cassert>
16 #include <stdlib.h>
17 
18 // namespace __cxxabiv1 {
19 //      void __cxa_decrement_exception_refcount(void *thrown_object) throw();
20 // }
21 
22 unsigned gCounter = 0;
23 
my_terminate()24 void my_terminate() { exit(0); }
25 
main()26 int main ()
27 {
28     // should not call std::terminate()
29     __cxxabiv1::__cxa_decrement_exception_refcount(nullptr);
30 
31     std::set_terminate(my_terminate);
32 
33     // should call std::terminate()
34     __cxxabiv1::__cxa_decrement_exception_refcount((void*) &gCounter);
35     assert(false);
36 
37     return 0;
38 }
39