From abba685fcda46bb775a8e34e66f6a176f0a780cb Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 14 Mar 2017 17:08:47 +0000 Subject: [PATCH] Implement LWG2784, and mark 2786, 2795, 2804, 2812, 2826, 2834, 2837 and 2838 as complete - since we do them already git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@297752 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/exception | 16 +++++---- .../except.nested/rethrow_if_nested.pass.cpp | 33 ++++++++++++++++++- www/cxx1z_status.html | 18 +++++----- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/include/exception b/include/exception index 8828709f8..216ae0c70 100644 --- a/include/exception +++ b/include/exception @@ -248,12 +248,17 @@ throw_with_nested (_Tp& __t, typename enable_if< #endif } +template +struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT( + is_polymorphic<_From>::value && + (!is_base_of<_To, _From>::value || + is_convertible::value)) {}; + template inline _LIBCPP_INLINE_VISIBILITY void -rethrow_if_nested(const _Ep& __e, typename enable_if< - is_polymorphic<_Ep>::value - >::type* = 0) +rethrow_if_nested(const _Ep& __e, + typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0) { const nested_exception* __nep = dynamic_cast(_VSTD::addressof(__e)); if (__nep) @@ -263,9 +268,8 @@ rethrow_if_nested(const _Ep& __e, typename enable_if< template inline _LIBCPP_INLINE_VISIBILITY void -rethrow_if_nested(const _Ep&, typename enable_if< - !is_polymorphic<_Ep>::value - >::type* = 0) +rethrow_if_nested(const _Ep&, + typename enable_if::value>::type* = 0) { } diff --git a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp index 57d193a41..68cd85038 100644 --- a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp @@ -46,12 +46,19 @@ public: C * operator&() const { assert(false); } // should not be called }; +class D : private std::nested_exception {}; + + +class E1 : public std::nested_exception {}; +class E2 : public std::nested_exception {}; +class E : public E1, public E2 {}; + int main() { { try { - A a(3); + A a(3); // not a polymorphic type --> no effect std::rethrow_if_nested(a); assert(true); } @@ -60,6 +67,30 @@ int main() assert(false); } } + { + try + { + D s; // inaccessible base class --> no effect + std::rethrow_if_nested(s); + assert(true); + } + catch (...) + { + assert(false); + } + } + { + try + { + E s; // ambiguous base class --> no effect + std::rethrow_if_nested(s); + assert(true); + } + catch (...) + { + assert(false); + } + } { try { diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html index b31cdc6de..b37043e03 100644 --- a/www/cxx1z_status.html +++ b/www/cxx1z_status.html @@ -436,28 +436,28 @@ 2769Redundant const in the return type of any_cast(const any&)KonaComplete 2781Contradictory requirements for std::function and std::reference_wrapperKonaComplete 2782scoped_allocator_adaptor constructors must be constrainedKona - 2784Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parseKona + 2784Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parseKonaComplete 2785quoted should work with basic_string_viewKona - 2786Annex C should mention shared_ptr changes for array supportKona + 2786Annex C should mention shared_ptr changes for array supportKonaComplete 2787§[file_status.cons] doesn't match class definitionKonaComplete 2788basic_string range mutators unintentionally require a default constructible allocatorKona 2789Equivalence of contained objectsKonaComplete 2790Missing specification of istreambuf_iterator::operator->Kona 2794Missing requirements for allocator pointersKona - 2795§[global.functions] provides incorrect example of ADL useKona + 2795§[global.functions] provides incorrect example of ADL useKonaComplete 2796tuple should be a literal typeKona 2801Default-constructibility of unique_ptrKona 2802shared_ptr constructor requirements for a deleterKona - 2804Unconditional constexpr default constructor for istream_iteratorKona + 2804Unconditional constexpr default constructor for istream_iteratorKonaComplete 2806Base class of bad_optional_accessKonaComplete 2807std::invoke should use std::is_nothrow_callableKona - 2812Range access is available with <string_view>Kona + 2812Range access is available with <string_view>KonaComplete 2824list::sort should say that the order of elements is unspecified if an exception is thrownKona - 2826string_view iterators use old wordingKona - 2834Resolution LWG 2223 is missing wording about end iteratorsKona + 2826string_view iterators use old wordingKonaComplete + 2834Resolution LWG 2223 is missing wording about end iteratorsKonaComplete 2835LWG 2536 seems to misspecify <tgmath.h>Kona - 2837gcd and lcm should support a wider range of input valuesKona - 2838is_literal_type specification needs a little cleanupKona + 2837gcd and lcm should support a wider range of input valuesKonaComplete + 2838is_literal_type specification needs a little cleanupKonaComplete 2842in_place_t check for optional::optional(U&&) should decay UKona 2850std::function move constructor does unnecessary workKona 2853Possible inconsistency in specification of erase in [vector.modifiers]Kona