2021-11-18 05:25:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2011-12-07 02:01:47 +08:00
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-12-07 02:01:47 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-04-17 22:29:15 +08:00
|
|
|
// UNSUPPORTED: no-exceptions
|
2016-05-31 20:01:32 +08:00
|
|
|
|
2011-06-10 11:40:19 +08:00
|
|
|
#include "cxxabi.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2012-07-11 17:37:56 +08:00
|
|
|
#include <stdlib.h>
|
2011-06-10 11:40:19 +08:00
|
|
|
#include <assert.h>
|
|
|
|
#include <exception>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2020-10-31 05:33:02 +08:00
|
|
|
// Disable warning about throw always calling terminate.
|
|
|
|
#if defined(__GNUC__) && !defined(__clang__)
|
|
|
|
# pragma GCC diagnostic ignored "-Wterminate"
|
|
|
|
#endif
|
|
|
|
|
2011-06-10 11:40:19 +08:00
|
|
|
// use dtors instead of try/catch
|
|
|
|
namespace test1 {
|
|
|
|
struct B {
|
|
|
|
~B() {
|
|
|
|
printf("should not be run\n");
|
|
|
|
exit(10);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
~A()
|
|
|
|
#if __has_feature(cxx_noexcept)
|
|
|
|
noexcept(false)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
B b;
|
|
|
|
throw 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // test1
|
|
|
|
|
|
|
|
void my_terminate() { exit(0); }
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void destroy(void* v)
|
|
|
|
{
|
|
|
|
T* t = static_cast<T*>(v);
|
|
|
|
t->~T();
|
|
|
|
}
|
|
|
|
|
2020-10-09 01:36:33 +08:00
|
|
|
int main(int, char**)
|
2011-06-10 11:40:19 +08:00
|
|
|
{
|
|
|
|
std::set_terminate(my_terminate);
|
|
|
|
{
|
|
|
|
typedef test1::A Array[10];
|
|
|
|
Array a[10]; // calls _cxa_vec_dtor
|
|
|
|
__cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
|
|
|
|
assert(false);
|
|
|
|
}
|
2020-10-09 01:36:33 +08:00
|
|
|
|
|
|
|
return 0;
|
2012-07-11 17:37:56 +08:00
|
|
|
}
|