blob: 67766aa2c46190a9f084e7d9d7e3425aab8fcebc [file] [log] [blame]
Howard Hinnanted2c2912010-05-27 17:06:52 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnanted2c2912010-05-27 17:06:52 +00007//
8//===----------------------------------------------------------------------===//
9
Asiri Rathnayakecc2e93c2015-11-10 11:41:22 +000010// XFAIL: libcpp-no-exceptions
Howard Hinnanted2c2912010-05-27 17:06:52 +000011// <exception>
12
13// class nested_exception;
14
15// nested_exception() throw();
16
17#include <exception>
18#include <cassert>
19
20class A
21{
22 int data_;
23public:
24 explicit A(int data) : data_(data) {}
25
26 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
27};
28
29int main()
30{
31 {
32 std::nested_exception e;
33 assert(e.nested_ptr() == nullptr);
34 }
35 {
36 try
37 {
38 throw A(2);
39 assert(false);
40 }
41 catch (const A&)
42 {
43 std::nested_exception e;
44 assert(e.nested_ptr() != nullptr);
45 try
46 {
47 rethrow_exception(e.nested_ptr());
48 assert(false);
49 }
50 catch (const A& a)
51 {
52 assert(a == A(2));
53 }
54 }
55 }
56}