From 10a803db2c8eae727d732c6969c71c7dda232bf2 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sun, 18 Jun 2017 14:52:26 +0000 Subject: [PATCH] any: Add availability for experimental::bad_any_cast As a follow up to r302172, add missing availability for bad_any_cast. rdar://problem/32161524 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305647 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__config | 5 +++++ include/experimental/any | 9 +++++---- .../experimental/any/any.class/any.assign/copy.pass.cpp | 7 +------ .../experimental/any/any.class/any.assign/move.pass.cpp | 7 +------ .../experimental/any/any.class/any.assign/value.pass.cpp | 7 +------ .../experimental/any/any.class/any.cons/copy.pass.cpp | 7 +------ .../experimental/any/any.class/any.cons/move.pass.cpp | 7 +------ .../experimental/any/any.class/any.cons/value.pass.cpp | 7 +------ .../any/any.class/any.modifiers/clear.pass.cpp | 7 +------ .../any/any.class/any.modifiers/swap.pass.cpp | 7 +------ test/support/experimental_any_helpers.h | 2 ++ 11 files changed, 20 insertions(+), 52 deletions(-) diff --git a/include/__config b/include/__config index fc24a3bc9..7358e52ec 100644 --- a/include/__config +++ b/include/__config @@ -1154,6 +1154,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( __attribute__((availability(watchos,strict,introduced=3.0))) #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable)) #define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable)) +#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable)) #define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \ __attribute__((availability(macosx,strict,introduced=10.12))) \ __attribute__((availability(ios,strict,introduced=10.0))) \ @@ -1179,6 +1180,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_AVAILABILITY_SHARED_MUTEX #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS #define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH +#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST #define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS #define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE #define _LIBCPP_AVAILABILITY_FUTURE_ERROR @@ -1191,9 +1193,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( #ifdef _LIBCPP_NO_EXCEPTIONS #define _LIBCPP_AVAILABILITY_DYNARRAY #define _LIBCPP_AVAILABILITY_FUTURE +#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST #else #define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH #define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR +#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST \ + _LIBCPP_AVAILABILITY_BAD_ANY_CAST #endif // Availability of stream API in the dylib got dropped and re-added. The diff --git a/include/experimental/any b/include/experimental/any index 022b379e8..083a29090 100644 --- a/include/experimental/any +++ b/include/experimental/any @@ -89,7 +89,7 @@ inline namespace fundamentals_v1 { _LIBCPP_BEGIN_NAMESPACE_LFTS -class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast +class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast { public: virtual const char* what() const _NOEXCEPT; @@ -98,6 +98,7 @@ public: #if _LIBCPP_STD_VER > 11 // C++ > 11 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE +_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { #ifndef _LIBCPP_NO_EXCEPTIONS @@ -506,7 +507,7 @@ void swap(any & __lhs, any & __rhs) _NOEXCEPT } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any const & __v) { static_assert( @@ -522,7 +523,7 @@ _ValueType any_cast(any const & __v) } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any & __v) { static_assert( @@ -537,7 +538,7 @@ _ValueType any_cast(any & __v) } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any && __v) { static_assert( diff --git a/test/std/experimental/any/any.class/any.assign/copy.pass.cpp b/test/std/experimental/any/any.class/any.assign/copy.pass.cpp index 7140fab88..0b9d71e5f 100644 --- a/test/std/experimental/any/any.class/any.assign/copy.pass.cpp +++ b/test/std/experimental/any/any.class/any.assign/copy.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/std/experimental/any/any.class/any.assign/move.pass.cpp b/test/std/experimental/any/any.class/any.assign/move.pass.cpp index 35fc56c24..72351aeae 100644 --- a/test/std/experimental/any/any.class/any.assign/move.pass.cpp +++ b/test/std/experimental/any/any.class/any.assign/move.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/std/experimental/any/any.class/any.assign/value.pass.cpp b/test/std/experimental/any/any.class/any.assign/value.pass.cpp index 8ff4ad594..cd4646fb5 100644 --- a/test/std/experimental/any/any.class/any.assign/value.pass.cpp +++ b/test/std/experimental/any/any.class/any.assign/value.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/std/experimental/any/any.class/any.cons/copy.pass.cpp b/test/std/experimental/any/any.class/any.cons/copy.pass.cpp index 47f12d739..d477394c0 100644 --- a/test/std/experimental/any/any.class/any.cons/copy.pass.cpp +++ b/test/std/experimental/any/any.class/any.cons/copy.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/std/experimental/any/any.class/any.cons/move.pass.cpp b/test/std/experimental/any/any.class/any.cons/move.pass.cpp index c5395daa3..ef980ca5f 100644 --- a/test/std/experimental/any/any.class/any.cons/move.pass.cpp +++ b/test/std/experimental/any/any.class/any.cons/move.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/std/experimental/any/any.class/any.cons/value.pass.cpp b/test/std/experimental/any/any.class/any.cons/value.pass.cpp index fcace5028..d37990e6c 100644 --- a/test/std/experimental/any/any.class/any.cons/value.pass.cpp +++ b/test/std/experimental/any/any.class/any.cons/value.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp b/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp index 1b0b75d61..a19bd38f1 100644 --- a/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp +++ b/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp b/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp index 9f499b4a1..8de582a6b 100644 --- a/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp +++ b/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp @@ -9,12 +9,7 @@ // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // diff --git a/test/support/experimental_any_helpers.h b/test/support/experimental_any_helpers.h index 50bd6d68f..9c906e6bf 100644 --- a/test/support/experimental_any_helpers.h +++ b/test/support/experimental_any_helpers.h @@ -55,6 +55,7 @@ void assertEmpty(std::experimental::any const& a) { // Assert that an 'any' object stores the specified 'Type' and 'value'. template +_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void assertContains(std::experimental::any const& a, int value = 1) { assert(!a.empty()); RTTI_ASSERT(a.type() == typeid(Type)); @@ -64,6 +65,7 @@ void assertContains(std::experimental::any const& a, int value = 1) { // Modify the value of a "test type" stored within an any to the specified // 'value'. template +_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void modifyValue(std::experimental::any& a, int value) { assert(!a.empty()); RTTI_ASSERT(a.type() == typeid(Type));