Louis Dionne | eb8650a | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
Asiri Rathnayake | 57e446d | 2016-05-31 12:01:32 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 3 | // 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 Rathnayake | 57e446d | 2016-05-31 12:01:32 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Louis Dionne | 31cbe0f | 2020-06-01 10:38:23 -0400 | [diff] [blame] | 9 | // UNSUPPORTED: c++03 |
Louis Dionne | 8c61114 | 2020-04-17 10:29:15 -0400 | [diff] [blame] | 10 | // REQUIRES: no-exceptions |
Asiri Rathnayake | 57e446d | 2016-05-31 12:01:32 +0000 | [diff] [blame] | 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 | |
| 21 | unsigned gCounter = 0; |
| 22 | |
| 23 | void my_terminate() { exit(0); } |
| 24 | |
| 25 | int 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 | } |