Home | History | Annotate | Download | only in test
      1 //===----------------------- noexception3.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_rethrow_primary_exception(void* thrown_object);
     20 // }
     21 
     22 unsigned gCounter = 0;
     23 
     24 void my_terminate() { exit(0); }
     25 
     26 int main ()
     27 {
     28     // should not call std::terminate()
     29     __cxxabiv1::__cxa_rethrow_primary_exception(nullptr);
     30 
     31     std::set_terminate(my_terminate);
     32 
     33     // should call std::terminate()
     34     __cxxabiv1::__cxa_rethrow_primary_exception((void*) &gCounter);
     35     assert(false);
     36 
     37     return 0;
     38 }
     39