blob: 3855027b5a25503131767e3d1a8ae11e99108afe [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>
Richard Smith4c50ea22012-07-11 09:37:56 +000013#include <stdlib.h>
Marshall Clow280ddee2011-06-10 03:40:19 +000014#include <assert.h>
15#include <exception>
16
17#include <memory>
18
19// use dtors instead of try/catch
20namespace test1 {
21 struct B {
22 ~B() {
23 printf("should not be run\n");
24 exit(10);
25 }
26};
27
28struct 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
40void my_terminate() { exit(0); }
41
42template <class T>
43void destroy(void* v)
44{
45 T* t = static_cast<T*>(v);
46 t->~T();
47}
48
49int 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 }
Richard Smith4c50ea22012-07-11 09:37:56 +000058}