blob: b377d9ec6b5852658724450ed086385e80ca60c1 [file] [log] [blame]
Asiri Rathnayake57e446d2016-05-31 12:01:321//===----------------------- noexception2.pass.cpp ------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:403// 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
Asiri Rathnayake57e446d2016-05-31 12:01:326//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++98, c++03
10// REQUIRES: libcxxabi-no-exceptions
11
12#include <cxxabi.h>
13#include <exception>
14#include <cassert>
15#include <stdlib.h>
16
17// namespace __cxxabiv1 {
18// void __cxa_decrement_exception_refcount(void *thrown_object) throw();
19// }
20
21unsigned gCounter = 0;
22
23void my_terminate() { exit(0); }
24
25int main ()
26{
27 // should not call std::terminate()
28 __cxxabiv1::__cxa_decrement_exception_refcount(nullptr);
29
30 std::set_terminate(my_terminate);
31
32 // should call std::terminate()
33 __cxxabiv1::__cxa_decrement_exception_refcount((void*) &gCounter);
34 assert(false);
35
36 return 0;
37}