summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/language.support/support.exception
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commit5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch)
treeafde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/language.support/support.exception
parentf11e8eab527fba316c64112f6e05de1a79693a3e (diff)
downloadbcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz
bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/language.support/support.exception')
-rw-r--r--libcxx/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp27
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp59
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp57
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp55
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp89
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp70
-rw-r--r--libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp103
-rw-r--r--libcxx/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp25
-rw-r--r--libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp23
-rw-r--r--libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp19
-rw-r--r--libcxx/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp26
-rw-r--r--libcxx/test/std/language.support/support.exception/exception/exception.pass.cpp25
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp269
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp34
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp49
-rw-r--r--libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp57
-rw-r--r--libcxx/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp45
-rw-r--r--libcxx/test/std/language.support/support.exception/version.pass.cpp20
19 files changed, 1064 insertions, 0 deletions
diff --git a/libcxx/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp b/libcxx/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp
new file mode 100644
index 00000000000..3baddaa898d
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_exception>::value),
+ "std::is_base_of<std::exception, std::bad_exception>::value");
+ static_assert(std::is_polymorphic<std::bad_exception>::value,
+ "std::is_polymorphic<std::bad_exception>::value");
+ std::bad_exception b;
+ std::bad_exception b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp
new file mode 100644
index 00000000000..cbe303c570d
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/except.nested/assign.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception& operator=(const nested_exception&) throw() = default;
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ {
+ std::nested_exception e0;
+ std::nested_exception e;
+ e = e0;
+ assert(e.nested_ptr() == nullptr);
+ }
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ std::nested_exception e0;
+ std::nested_exception e;
+ e = e0;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ rethrow_exception(e.nested_ptr());
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
new file mode 100644
index 00000000000..bfa13707a97
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception(const nested_exception&) throw() = default;
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ {
+ std::nested_exception e0;
+ std::nested_exception e = e0;
+ assert(e.nested_ptr() == nullptr);
+ }
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ std::nested_exception e0;
+ std::nested_exception e = e0;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ rethrow_exception(e.nested_ptr());
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
new file mode 100644
index 00000000000..1422f770eca
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception() throw();
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ {
+ std::nested_exception e;
+ assert(e.nested_ptr() == nullptr);
+ }
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ std::nested_exception e;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ rethrow_exception(e.nested_ptr());
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
new file mode 100644
index 00000000000..567ed579eb7
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// template <class E> void rethrow_if_nested(const E& e);
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+ virtual ~A() _NOEXCEPT {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+class B
+ : public std::nested_exception,
+ public A
+{
+public:
+ explicit B(int data) : A(data) {}
+ B(const B& b) : A(b) {}
+};
+
+int main()
+{
+ {
+ try
+ {
+ A a(3);
+ std::rethrow_if_nested(a);
+ assert(true);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ }
+ {
+ try
+ {
+ throw B(5);
+ }
+ catch (const B& b)
+ {
+ try
+ {
+ throw b;
+ }
+ catch (const A& a)
+ {
+ try
+ {
+ std::rethrow_if_nested(a);
+ assert(false);
+ }
+ catch (const B& b)
+ {
+ assert(b == B(5));
+ }
+ }
+ }
+ }
+ {
+ try
+ {
+ std::rethrow_if_nested(1);
+ assert(true);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
new file mode 100644
index 00000000000..b07269061b4
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// void rethrow_nested [[noreturn]] () const;
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+void go_quietly()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ {
+ try
+ {
+ throw A(2);
+ assert(false);
+ }
+ catch (const A&)
+ {
+ const std::nested_exception e;
+ assert(e.nested_ptr() != nullptr);
+ try
+ {
+ e.rethrow_nested();
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(2));
+ }
+ }
+ }
+ {
+ try
+ {
+ std::set_terminate(go_quietly);
+ const std::nested_exception e;
+ e.rethrow_nested();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
new file mode 100644
index 00000000000..887264a5c6f
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// template<class T> void throw_with_nested [[noreturn]] (T&& t);
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ explicit A(int data) : data_(data) {}
+
+ friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+class B
+ : public std::nested_exception
+{
+ int data_;
+public:
+ explicit B(int data) : data_(data) {}
+
+ friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ {
+ try
+ {
+ A a(3);
+ std::throw_with_nested(a);
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(a == A(3));
+ }
+ }
+ {
+ try
+ {
+ A a(4);
+ std::throw_with_nested(a);
+ assert(false);
+ }
+ catch (const std::nested_exception& e)
+ {
+ assert(e.nested_ptr() == nullptr);
+ }
+ }
+ {
+ try
+ {
+ B b(5);
+ std::throw_with_nested(b);
+ assert(false);
+ }
+ catch (const B& b)
+ {
+ assert(b == B(5));
+ }
+ }
+ {
+ try
+ {
+ B b(6);
+ std::throw_with_nested(b);
+ assert(false);
+ }
+ catch (const std::nested_exception& e)
+ {
+ assert(e.nested_ptr() == nullptr);
+ const B& b = dynamic_cast<const B&>(e);
+ assert(b == B(6));
+ }
+ }
+ {
+ try
+ {
+ int i = 7;
+ std::throw_with_nested(i);
+ assert(false);
+ }
+ catch (int i)
+ {
+ assert(i == 7);
+ }
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp b/libcxx/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp b/libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp
new file mode 100644
index 00000000000..82ae4aaa88d
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test get_terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+ std::set_terminate(f1);
+ assert(std::get_terminate() == f1);
+ std::set_terminate(f2);
+ assert(std::get_terminate() == f2);
+}
diff --git a/libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp b/libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
new file mode 100644
index 00000000000..c4bff603ebb
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+ std::set_terminate(f1);
+ assert(std::set_terminate(f2) == f1);
+}
diff --git a/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
new file mode 100644
index 00000000000..232ce0a5a88
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test terminate_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+ std::terminate_handler p = f;
+}
diff --git a/libcxx/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp
new file mode 100644
index 00000000000..3199d9b9ea9
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_terminate(f1);
+ std::terminate();
+ assert(false);
+}
diff --git a/libcxx/test/std/language.support/support.exception/exception/exception.pass.cpp b/libcxx/test/std/language.support/support.exception/exception/exception.pass.cpp
new file mode 100644
index 00000000000..ad53b6ebfe5
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/exception/exception.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert(std::is_polymorphic<std::exception>::value,
+ "std::is_polymorphic<std::exception>::value");
+ std::exception b;
+ std::exception b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
new file mode 100644
index 00000000000..9ff0d6e2ce4
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
@@ -0,0 +1,269 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// exception_ptr current_exception();
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ static int constructed;
+
+ A() {++constructed;}
+ ~A() {--constructed;}
+ A(const A&) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(p == nullptr);
+ }
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p2;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p2 = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p == p2);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p2;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (A& a)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p2 = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p == p2);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p2;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (A a)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 2);
+ assert(p != nullptr);
+ p2 = std::current_exception();
+ assert(A::constructed == 2);
+ assert(p == p2);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ }
+ assert(A::constructed == 0);
+ }
+ assert(A::constructed == 0);
+ {
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ std::exception_ptr p = std::current_exception();
+ assert(A::constructed == 0);
+ assert(p == nullptr);
+ }
+ assert(A::constructed == 0);
+ {
+ std::exception_ptr p;
+ try
+ {
+ assert(A::constructed == 0);
+ throw A();
+ assert(false);
+ }
+ catch (...)
+ {
+ assert(A::constructed == 1);
+ try
+ {
+ assert(A::constructed == 1);
+ throw;
+ assert(false);
+ }
+ catch (...)
+ {
+ p = std::current_exception();
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ }
+ assert(A::constructed == 0);
+}
diff --git a/libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp
new file mode 100644
index 00000000000..3aa8dcf55bb
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// typedef unspecified exception_ptr;
+
+// exception_ptr shall satisfy the requirements of NullablePointer.
+
+#include <exception>
+#include <cassert>
+
+int main()
+{
+ std::exception_ptr p;
+ assert(p == nullptr);
+ std::exception_ptr p2 = p;
+ assert(nullptr == p);
+ assert(!p);
+ assert(p2 == p);
+ p2 = p;
+ assert(p2 == p);
+ assert(p2 == nullptr);
+ std::exception_ptr p3 = nullptr;
+ assert(p3 == nullptr);
+ p3 = nullptr;
+ assert(p3 == nullptr);
+}
diff --git a/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
new file mode 100644
index 00000000000..89c9f85d381
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// template<class E> exception_ptr make_exception_ptr(E e);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ static int constructed;
+ int data_;
+
+ A(int data = 0) : data_(data) {++constructed;}
+ ~A() {--constructed;}
+ A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+ {
+ std::exception_ptr p = std::make_exception_ptr(A(5));
+ try
+ {
+ std::rethrow_exception(p);
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p = nullptr;
+ assert(p == nullptr);
+ assert(a.data_ == 5);
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
new file mode 100644
index 00000000000..e47a5989d41
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// void rethrow_exception [[noreturn]] (exception_ptr p);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ static int constructed;
+ int data_;
+
+ A(int data = 0) : data_(data) {++constructed;}
+ ~A() {--constructed;}
+ A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+ {
+ std::exception_ptr p;
+ try
+ {
+ throw A(3);
+ }
+ catch (...)
+ {
+ p = std::current_exception();
+ }
+ try
+ {
+ std::rethrow_exception(p);
+ assert(false);
+ }
+ catch (const A& a)
+ {
+ assert(A::constructed == 1);
+ assert(p != nullptr);
+ p = nullptr;
+ assert(p == nullptr);
+ assert(a.data_ == 3);
+ assert(A::constructed == 1);
+ }
+ assert(A::constructed == 0);
+ }
+}
diff --git a/libcxx/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp b/libcxx/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
new file mode 100644
index 00000000000..22d8d8e982a
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test uncaught_exception
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+ ~A()
+ {
+ assert(std::uncaught_exception());
+ }
+};
+
+struct B
+{
+ B()
+ {
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
+ assert(!std::uncaught_exception());
+ }
+};
+
+int main()
+{
+ try
+ {
+ A a;
+ assert(!std::uncaught_exception());
+ throw B();
+ }
+ catch (...)
+ {
+ assert(!std::uncaught_exception());
+ }
+ assert(!std::uncaught_exception());
+}
diff --git a/libcxx/test/std/language.support/support.exception/version.pass.cpp b/libcxx/test/std/language.support/support.exception/version.pass.cpp
new file mode 100644
index 00000000000..acdedbb31fe
--- /dev/null
+++ b/libcxx/test/std/language.support/support.exception/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+#include <exception>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
OpenPOWER on IntegriCloud