Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / language.support / support.exception / except.nested / ctor_copy.pass.cpp
blobe1547575a85a895fa7d23f65412c5293b55935c3
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 // <exception>
11 // class nested_exception;
13 // nested_exception(const nested_exception&) throw() = default;
15 #include <exception>
16 #include <cassert>
18 #include "test_macros.h"
20 class A
22 int data_;
23 public:
24 explicit A(int data) : data_(data) {}
26 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
29 int main(int, char**)
32 std::nested_exception e0;
33 std::nested_exception e = e0;
34 assert(e.nested_ptr() == nullptr);
36 #ifndef TEST_HAS_NO_EXCEPTIONS
38 try
40 throw A(2);
41 assert(false);
43 catch (const A&)
45 std::nested_exception e0;
46 std::nested_exception e = e0;
47 assert(e.nested_ptr() != nullptr);
48 try
50 std::rethrow_exception(e.nested_ptr());
51 assert(false);
53 catch (const A& a)
55 assert(a == A(2));
59 #endif
61 return 0;