Home | History | Annotate | Download | only in test
      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 {
     22          ~B() {
     23             printf("should not be run\n");
     24             exit(10);
     25             }
     26 };
     27 
     28 struct A {
     29  ~A()
     30 #if __has_feature(cxx_noexcept)
     31     noexcept(false)
     32 #endif
     33  {
     34    B b;
     35    throw 0;
     36  }
     37 };
     38 }  // test1
     39 
     40 void my_terminate() { exit(0); }
     41 
     42 template <class T>
     43 void destroy(void* v)
     44 {
     45   T* t = static_cast<T*>(v);
     46   t->~T();
     47 }
     48 
     49 int main( int argc, char *argv [])
     50 {
     51   std::set_terminate(my_terminate);
     52   {
     53   typedef test1::A Array[10];
     54   Array a[10]; // calls _cxa_vec_dtor
     55   __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
     56   assert(false);
     57   }
     58 }
     59