blob: 393683766717efe1c1e69b5953abb372f08593c9 [file] [log] [blame]
Howard Hinnant987afbe2011-12-06 18:01:47 +00001//===------------------------- 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
Marshall Clow280ddee2011-06-10 03:40:19 +000010#include "cxxabi.h"
11
12#include <stdio.h>
13#include <assert.h>
14#include <exception>
15
16#include <memory>
17
18// use dtors instead of try/catch
19namespace test1 {
20 struct B {
21 ~B() {
22 printf("should not be run\n");
23 exit(10);
24 }
25};
26
27struct A {
28 ~A()
29#if __has_feature(cxx_noexcept)
30 noexcept(false)
31#endif
32 {
33 B b;
34 throw 0;
35 }
36};
37} // test1
38
39void my_terminate() { exit(0); }
40
41template <class T>
42void destroy(void* v)
43{
44 T* t = static_cast<T*>(v);
45 t->~T();
46}
47
48int main( int argc, char *argv [])
49{
50 std::set_terminate(my_terminate);
51 {
52 typedef test1::A Array[10];
53 Array a[10]; // calls _cxa_vec_dtor
54 __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
55 assert(false);
56 }
57}