Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxxabi / test / test_vector3.pass.cpp
blobe1a4154c155c80d53fd831281685c74a6ef9aba9
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-exceptions
11 #include "cxxabi.h"
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <assert.h>
16 #include <exception>
18 #include <memory>
20 // Disable warning about throw always calling terminate.
21 #if defined(__GNUC__) && !defined(__clang__)
22 # pragma GCC diagnostic ignored "-Wterminate"
23 #endif
25 // use dtors instead of try/catch
26 namespace test1 {
27 struct B {
28 ~B() {
29 printf("should not be run\n");
30 exit(10);
34 struct A {
35 ~A()
36 #if __has_feature(cxx_noexcept)
37 noexcept(false)
38 #endif
40 B b;
41 throw 0;
44 } // test1
46 void my_terminate() { exit(0); }
48 template <class T>
49 void destroy(void* v)
51 T* t = static_cast<T*>(v);
52 t->~T();
55 int main(int, char**)
57 std::set_terminate(my_terminate);
59 typedef test1::A Array[10];
60 Array a[10]; // calls _cxa_vec_dtor
61 __cxxabiv1::__cxa_vec_dtor(a, 10, sizeof(test1::A), destroy<test1::A>);
62 assert(false);
65 return 0;