1 //===------------------------- test_vector3.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 #include "cxxabi.h"
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <assert.h>
15 #include <exception>
16 
17 //#include <memory>
18 
19 // use dtors instead of try/catch
20 namespace test1 {
21     struct B {
~Btest1::B22          ~B() {
23             printf("should not be run\n");
24             exit(10);
25             }
26 };
27 
28 struct A {
~Atest1::A29  ~A()
30 #if __cplusplus >= 201103L
31     noexcept(false)
32 #endif
33  {
34    B b;
35    throw 0;
36  }
37 };
38 }  // test1
39 
my_terminate()40 void my_terminate() { exit(0); }
41 
42 #ifdef __arm__
43 #define CTOR_RETURN_TYPE void*
44 #define CTOR_RETURN(x) return x
45 #else
46 #define CTOR_RETURN_TYPE void
47 #define CTOR_RETURN(x) return
48 #endif
49 
50 template <class T>
destroy(void * v)51 CTOR_RETURN_TYPE destroy(void* v)
52 {
53   T* t = static_cast<T*>(v);
54   t->~T();
55   CTOR_RETURN(v);
56 }
57 
main(int argc,char * argv[])58 int main( int argc, char *argv [])
59 {
60   std::set_terminate(my_terminate);
61   {
62   typedef test1::A Array[10];
63   Array a[10]; // calls _cxa_vec_dtor
64   __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
65   assert(false);
66   }
67 }
68