blob: 59d59a7f966406ff1a1c5e5725b586b872258136 [file] [log] [blame]
Asiri Rathnayake4174e8b2016-05-31 12:01:32 +00001//===----------------------- noexception1.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_increment_exception_refcount(void *thrown_object) throw();
20// }
21
22unsigned gCounter = 0;
23
24void my_terminate() { exit(0); }
25
26int main ()
27{
28 // should not call std::terminate()
29 __cxxabiv1::__cxa_increment_exception_refcount(nullptr);
30
31 std::set_terminate(my_terminate);
32
33 // should call std::terminate()
34 __cxxabiv1::__cxa_increment_exception_refcount((void*) &gCounter);
35 assert(false);
36
37 return 0;
38}