150
|
1 //===------------------------- test_vector3.cpp ---------------------------===//
|
|
2 //
|
|
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
|
|
6 //
|
|
7 //===----------------------------------------------------------------------===//
|
|
8
|
173
|
9 // UNSUPPORTED: no-exceptions
|
150
|
10
|
|
11 #include "cxxabi.h"
|
|
12
|
|
13 #include <stdio.h>
|
|
14 #include <stdlib.h>
|
|
15 #include <assert.h>
|
|
16 #include <exception>
|
|
17
|
|
18 #include <memory>
|
|
19
|
|
20 // use dtors instead of try/catch
|
|
21 namespace test1 {
|
|
22 struct B {
|
|
23 ~B() {
|
|
24 printf("should not be run\n");
|
|
25 exit(10);
|
|
26 }
|
|
27 };
|
|
28
|
|
29 struct A {
|
|
30 ~A()
|
|
31 #if __has_feature(cxx_noexcept)
|
|
32 noexcept(false)
|
|
33 #endif
|
|
34 {
|
|
35 B b;
|
|
36 throw 0;
|
|
37 }
|
|
38 };
|
|
39 } // test1
|
|
40
|
|
41 void my_terminate() { exit(0); }
|
|
42
|
|
43 template <class T>
|
|
44 void destroy(void* v)
|
|
45 {
|
|
46 T* t = static_cast<T*>(v);
|
|
47 t->~T();
|
|
48 }
|
|
49
|
|
50 int main()
|
|
51 {
|
|
52 std::set_terminate(my_terminate);
|
|
53 {
|
|
54 typedef test1::A Array[10];
|
|
55 Array a[10]; // calls _cxa_vec_dtor
|
|
56 __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
|
|
57 assert(false);
|
|
58 }
|
|
59 }
|