blob: 081c2d07ad2b678644b0ef87c28d58f01385597e [file] [log] [blame]
Asiri Rathnayake4174e8b2016-05-31 12:01:32 +00001//===----------------------- 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
22unsigned gCounter = 0;
23
24void my_terminate() { exit(0); }
25
26int 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}