Howard Hinnant | b9f2cc8 | 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 | |
Asiri Rathnayake | 4174e8b | 2016-05-31 12:01:32 +0000 | [diff] [blame] | 10 | // UNSUPPORTED: libcxxabi-no-exceptions |
| 11 | |
Marshall Clow | e52bde4 | 2011-06-10 03:40:19 +0000 | [diff] [blame] | 12 | #include "cxxabi.h" |
| 13 | |
| 14 | #include <stdio.h> |
Richard Smith | 921769d | 2012-07-11 09:37:56 +0000 | [diff] [blame] | 15 | #include <stdlib.h> |
Marshall Clow | e52bde4 | 2011-06-10 03:40:19 +0000 | [diff] [blame] | 16 | #include <assert.h> |
| 17 | #include <exception> |
| 18 | |
| 19 | #include <memory> |
| 20 | |
| 21 | // use dtors instead of try/catch |
| 22 | namespace test1 { |
| 23 | struct B { |
| 24 | ~B() { |
| 25 | printf("should not be run\n"); |
| 26 | exit(10); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | struct 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 | |
| 42 | void my_terminate() { exit(0); } |
| 43 | |
| 44 | template <class T> |
| 45 | void destroy(void* v) |
| 46 | { |
| 47 | T* t = static_cast<T*>(v); |
| 48 | t->~T(); |
| 49 | } |
| 50 | |
Eric Fiselier | 08bf03c | 2016-12-24 00:37:13 +0000 | [diff] [blame] | 51 | int main() |
Marshall Clow | e52bde4 | 2011-06-10 03:40:19 +0000 | [diff] [blame] | 52 | { |
| 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 Smith | 921769d | 2012-07-11 09:37:56 +0000 | [diff] [blame] | 60 | } |