Howard Hinnant | 987afbe | 2011-12-06 18:01:47 +0000 | [diff] [blame] | 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 | |
Marshall Clow | 280ddee | 2011-06-10 03:40:19 +0000 | [diff] [blame] | 10 | #include "cxxabi.h" |
| 11 | |
| 12 | #include <stdio.h> |
Richard Smith | 4c50ea2 | 2012-07-11 09:37:56 +0000 | [diff] [blame] | 13 | #include <stdlib.h> |
Marshall Clow | 280ddee | 2011-06-10 03:40:19 +0000 | [diff] [blame] | 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 | } |
Richard Smith | 4c50ea2 | 2012-07-11 09:37:56 +0000 | [diff] [blame] | 58 | } |