blob: 2f983ef717796921564a20d0e1c546b3dfca5dcf [file] [log] [blame]
Howard Hinnantb9f2cc82011-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
Asiri Rathnayake4174e8b2016-05-31 12:01:32 +000010// UNSUPPORTED: libcxxabi-no-exceptions
11
Marshall Clowe52bde42011-06-10 03:40:19 +000012#include "cxxabi.h"
13
14#include <stdio.h>
Richard Smith921769d2012-07-11 09:37:56 +000015#include <stdlib.h>
Marshall Clowe52bde42011-06-10 03:40:19 +000016#include <assert.h>
17#include <exception>
18
19#include <memory>
20
21// use dtors instead of try/catch
22namespace test1 {
23 struct B {
24 ~B() {
25 printf("should not be run\n");
26 exit(10);
27 }
28};
29
30struct A {
31 ~A()
32#if __has_feature(cxx_noexcept)
33 noexcept(false)
34#endif
35 {
36 B b;
37 throw 0;
38 }
39};
40} // test1
41
42void my_terminate() { exit(0); }
43
44template <class T>
45void destroy(void* v)
46{
47 T* t = static_cast<T*>(v);
48 t->~T();
49}
50
Eric Fiselier08bf03c2016-12-24 00:37:13 +000051int main()
Marshall Clowe52bde42011-06-10 03:40:19 +000052{
53 std::set_terminate(my_terminate);
54 {
55 typedef test1::A Array[10];
56 Array a[10]; // calls _cxa_vec_dtor
57 __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
58 assert(false);
59 }
Richard Smith921769d2012-07-11 09:37:56 +000060}