From 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 6 Sep 2015 18:46:46 +0000 Subject: Import libc++ 3.7.0 release (r246257). --- .../except.nested/assign.pass.cpp | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/std/language.support/support.exception/except.nested/assign.pass.cpp (limited to 'test/std/language.support/support.exception/except.nested/assign.pass.cpp') diff --git a/test/std/language.support/support.exception/except.nested/assign.pass.cpp b/test/std/language.support/support.exception/except.nested/assign.pass.cpp new file mode 100644 index 000000000000..cbe303c570d6 --- /dev/null +++ b/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. +// +//===----------------------------------------------------------------------===// + +// + +// class nested_exception; + +// nested_exception& operator=(const nested_exception&) throw() = default; + +#include +#include + +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)); + } + } + } +} -- cgit v1.2.3