From ea5cd3b4760ebe1b0ad4469aa9ba221e00795c51 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Sun, 23 Sep 2018 18:35:00 +0000 Subject: [PATCH] [libc++] Add deprecated attributes to many deprecated components Summary: These deprecation warnings are opt-in: they are only enabled when the _LIBCXX_DEPRECATION_WARNINGS macro is defined, which is not the case by default. Note that this is a first step in the right direction, but I wasn't able to get an exhaustive list of all deprecated components per standard, so there's certainly stuff that's missing. The list of components this commit marks as deprecated is: in C++11: - auto_ptr, auto_ptr_ref - binder1st, binder2nd, bind1st(), bind2nd() - pointer_to_unary_function, pointer_to_binary_function, ptr_fun() - mem_fun_t, mem_fun1_t, const_mem_fun_t, const_mem_fun1_t, mem_fun() - mem_fun_ref_t, mem_fun1_ref_t, const_mem_fun_ref_t, const_mem_fun1_ref_t, mem_fun_ref() in C++14: - random_shuffle() in C++17: - unary_negate, binary_negate, not1(), not2() Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D48912 llvm-svn: 342843 --- libcxx/docs/UsingLibcxx.rst | 5 ++ libcxx/include/__config | 32 +++++++- libcxx/include/__functional_base | 6 +- libcxx/include/algorithm | 4 +- libcxx/include/functional | 73 +++++++++-------- libcxx/include/memory | 16 ++-- .../random_shuffle.cxx1z.pass.cpp | 4 +- .../random_shuffle.depr_in_cxx14.fail.cpp | 54 +++++++++++++ .../auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp | 44 +++++++++++ .../adaptors.depr_in_cxx11.fail.cpp | 79 +++++++++++++++++++ .../bind1st.depr_in_cxx11.fail.cpp | 34 ++++++++ .../bind2nd.depr_in_cxx11.fail.cpp | 34 ++++++++ .../binder1st.depr_in_cxx11.fail.cpp | 34 ++++++++ .../binder2nd.depr_in_cxx11.fail.cpp | 34 ++++++++ .../binary_negate.depr_in_cxx17.fail.cpp | 38 +++++++++ .../negators/not1.depr_in_cxx17.fail.cpp | 36 +++++++++ .../negators/not2.depr_in_cxx17.fail.cpp | 37 +++++++++ .../unary_negate.depr_in_cxx17.fail.cpp | 37 +++++++++ 18 files changed, 551 insertions(+), 50 deletions(-) create mode 100644 libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp create mode 100644 libcxx/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp create mode 100644 libcxx/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp create mode 100644 libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.depr_in_cxx11.fail.cpp create mode 100644 libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.depr_in_cxx11.fail.cpp create mode 100644 libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.depr_in_cxx11.fail.cpp create mode 100644 libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.depr_in_cxx11.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.fail.cpp create mode 100644 libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.fail.cpp diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst index 993c8d7c41ec..41f4106846b4 100644 --- a/libcxx/docs/UsingLibcxx.rst +++ b/libcxx/docs/UsingLibcxx.rst @@ -240,6 +240,11 @@ thread safety annotations. purely as an extension. See :ref:`Extended Applications of [[nodiscard]] ` for more information. +**_LIBCPP_ENABLE_DEPRECATION_WARNINGS**: + This macro enables warnings when using deprecated components. For example, + when compiling in C++11 mode, using `std::auto_ptr` with the macro defined + will trigger a warning saying that `std::auto_ptr` is deprecated. By default, + this macro is not defined. C++17 Specific Configuration Macros ----------------------------------- diff --git a/libcxx/include/__config b/libcxx/include/__config index fc0498d6a7bb..2e1eb8d2981b 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1017,18 +1017,42 @@ template struct __static_assert_check {}; #define _LIBCPP_WCTYPE_IS_MASK #endif -#if _LIBCPP_STD_VER > 11 -# define _LIBCPP_DEPRECATED [[deprecated]] +// Deprecation macros. +// Deprecations warnings are only enabled when _LIBCPP_ENABLE_DEPRECATION_WARNINGS is defined. +#if defined(_LIBCPP_ENABLE_DEPRECATION_WARNINGS) +# if __has_attribute(deprecated) +# define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) +# elif _LIBCPP_STD_VER > 11 +# define _LIBCPP_DEPRECATED [[deprecated]] +# else +# define _LIBCPP_DEPRECATED +# endif #else # define _LIBCPP_DEPRECATED #endif +#if !defined(_LIBCPP_CXX03_LANG) +# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED +#else +# define _LIBCPP_DEPRECATED_IN_CXX11 +#endif + +#if _LIBCPP_STD_VER >= 14 +# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED +#else +# define _LIBCPP_DEPRECATED_IN_CXX14 +#endif + +#if _LIBCPP_STD_VER >= 17 +# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED +#else +# define _LIBCPP_DEPRECATED_IN_CXX17 +#endif + #if _LIBCPP_STD_VER <= 11 # define _LIBCPP_EXPLICIT_AFTER_CXX11 -# define _LIBCPP_DEPRECATED_AFTER_CXX11 #else # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit -# define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] #endif #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) diff --git a/libcxx/include/__functional_base b/libcxx/include/__functional_base index 57fdf2b9f663..1887974398be 100644 --- a/libcxx/include/__functional_base +++ b/libcxx/include/__functional_base @@ -50,7 +50,7 @@ template #endif struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool> { - _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x < __y;} }; @@ -59,7 +59,7 @@ struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool> template <> struct _LIBCPP_TEMPLATE_VIS less { - template + template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) @@ -552,7 +552,7 @@ template struct __is_transparent : false_type {}; template -struct __is_transparent<_Tp, _Up, +struct __is_transparent<_Tp, _Up, typename __void_t::type> : true_type {}; #endif diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 1359fda53b50..c5c17296e686 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -2952,7 +2952,7 @@ public: _LIBCPP_FUNC_VIS __rs_default __rs_get(); template -void +_LIBCPP_DEPRECATED_IN_CXX14 void random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; @@ -2973,7 +2973,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) } template -void +_LIBCPP_DEPRECATED_IN_CXX14 void random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, #ifndef _LIBCPP_CXX03_LANG _RandomNumberGenerator&& __rand) diff --git a/libcxx/include/functional b/libcxx/include/functional index 99ffb7e9f6ab..61c87b02c70c 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -183,7 +183,7 @@ struct bit_xor : unary_function }; template -class unary_negate +class unary_negate // deprecated in C++17 : public unary_function { public: @@ -191,10 +191,11 @@ public: bool operator()(const typename Predicate::argument_type& x) const; }; -template unary_negate not1(const Predicate& pred); +template // deprecated in C++17 +unary_negate not1(const Predicate& pred); template -class binary_negate +class binary_negate // deprecated in C++17 : public binary_function @@ -205,7 +206,8 @@ public: const typename Predicate::second_argument_type& y) const; }; -template binary_negate not2(const Predicate& pred); +template // deprecated in C++17 +binary_negate not2(const Predicate& pred); template unspecified not_fn(F&& f); // C++17 @@ -981,7 +983,7 @@ struct _LIBCPP_TEMPLATE_VIS bit_not #endif template -class _LIBCPP_TEMPLATE_VIS unary_negate +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public unary_function { _Predicate __pred_; @@ -995,12 +997,12 @@ public: }; template -inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY unary_negate<_Predicate> not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} template -class _LIBCPP_TEMPLATE_VIS binary_negate +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate : public binary_function @@ -1017,13 +1019,13 @@ public: }; template -inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY binary_negate<_Predicate> not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) template -class _LIBCPP_TEMPLATE_VIS binder1st +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st : public unary_function { @@ -1043,13 +1045,13 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY binder1st<__Operation> bind1st(const __Operation& __op, const _Tp& __x) {return binder1st<__Operation>(__op, __x);} template -class _LIBCPP_TEMPLATE_VIS binder2nd +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd : public unary_function { @@ -1069,13 +1071,13 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY binder2nd<__Operation> bind2nd(const __Operation& __op, const _Tp& __x) {return binder2nd<__Operation>(__op, __x);} template -class _LIBCPP_TEMPLATE_VIS pointer_to_unary_function +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public unary_function<_Arg, _Result> { _Result (*__f_)(_Arg); @@ -1087,13 +1089,13 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY pointer_to_unary_function<_Arg,_Result> ptr_fun(_Result (*__f)(_Arg)) {return pointer_to_unary_function<_Arg,_Result>(__f);} template -class _LIBCPP_TEMPLATE_VIS pointer_to_binary_function +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public binary_function<_Arg1, _Arg2, _Result> { _Result (*__f_)(_Arg1, _Arg2); @@ -1105,13 +1107,14 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY pointer_to_binary_function<_Arg1,_Arg2,_Result> ptr_fun(_Result (*__f)(_Arg1,_Arg2)) {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} template -class _LIBCPP_TEMPLATE_VIS mem_fun_t : public unary_function<_Tp*, _Sp> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t + : public unary_function<_Tp*, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -1122,7 +1125,8 @@ public: }; template -class _LIBCPP_TEMPLATE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t + : public binary_function<_Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -1133,19 +1137,20 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY mem_fun_t<_Sp,_Tp> mem_fun(_Sp (_Tp::*__f)()) {return mem_fun_t<_Sp,_Tp>(__f);} template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY mem_fun1_t<_Sp,_Tp,_Ap> mem_fun(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template -class _LIBCPP_TEMPLATE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t + : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -1156,7 +1161,8 @@ public: }; template -class _LIBCPP_TEMPLATE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t + : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -1167,19 +1173,20 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY mem_fun_ref_t<_Sp,_Tp> mem_fun_ref(_Sp (_Tp::*__f)()) {return mem_fun_ref_t<_Sp,_Tp>(__f);} template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} template -class _LIBCPP_TEMPLATE_VIS const_mem_fun_t : public unary_function +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t + : public unary_function { _Sp (_Tp::*__p_)() const; public: @@ -1190,7 +1197,8 @@ public: }; template -class _LIBCPP_TEMPLATE_VIS const_mem_fun1_t : public binary_function +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t + : public binary_function { _Sp (_Tp::*__p_)(_Ap) const; public: @@ -1201,19 +1209,20 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY const_mem_fun_t<_Sp,_Tp> mem_fun(_Sp (_Tp::*__f)() const) {return const_mem_fun_t<_Sp,_Tp>(__f);} template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY const_mem_fun1_t<_Sp,_Tp,_Ap> mem_fun(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template -class _LIBCPP_TEMPLATE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t + : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)() const; public: @@ -1224,7 +1233,7 @@ public: }; template -class _LIBCPP_TEMPLATE_VIS const_mem_fun1_ref_t +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; @@ -1236,13 +1245,13 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY const_mem_fun_ref_t<_Sp,_Tp> mem_fun_ref(_Sp (_Tp::*__f)() const) {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} template -inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY const_mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} diff --git a/libcxx/include/memory b/libcxx/include/memory index 37bd8cd4c63c..df629b930ddd 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -212,10 +212,10 @@ template template ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n); -template struct auto_ptr_ref {}; // removed in C++17 +template struct auto_ptr_ref {}; // deprecated in C++11, removed in C++17 template -class auto_ptr // removed in C++17 +class auto_ptr // deprecated in C++11, removed in C++17 { public: typedef X element_type; @@ -1783,7 +1783,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator() _NOEXCEPT {} - template + template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator(const allocator<_Up>&) _NOEXCEPT {} @@ -1791,7 +1791,7 @@ public: {return _VSTD::addressof(__x);} _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT {return _VSTD::addressof(__x);} - _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator::const_pointer = 0) { if (__n > max_size()) @@ -1888,7 +1888,7 @@ public: allocator() _NOEXCEPT {} template - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator(const allocator<_Up>&) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT @@ -2057,13 +2057,13 @@ void return_temporary_buffer(_Tp* __p) _NOEXCEPT #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) template -struct auto_ptr_ref +struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref { _Tp* __ptr_; }; template -class _LIBCPP_TEMPLATE_VIS auto_ptr +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr { private: _Tp* __ptr_; @@ -2107,7 +2107,7 @@ public: }; template <> -class _LIBCPP_TEMPLATE_VIS auto_ptr +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr { public: typedef void element_type; diff --git a/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp b/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp index 28a9281b49c2..58ce689981ca 100644 --- a/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp +++ b/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -// +// // template // void @@ -23,6 +23,8 @@ // However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE // is defined before including , then random_shuffle will be restored. +// REQUIRES: verify-support + // MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE diff --git a/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp b/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp new file mode 100644 index 000000000000..cf9925bc3264 --- /dev/null +++ b/libcxx/test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.fail.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last); +// +// template +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last, +// RandomNumberGenerator& rand); + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE + +#include +#include + +#include "test_macros.h" + +struct gen +{ + std::ptrdiff_t operator()(std::ptrdiff_t n) + { + return n-1; + } +}; + + +int main() +{ +#if TEST_STD_VER < 14 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'random_shuffle' is deprecated}} + // expected-error@* 1 {{'random_shuffle' is deprecated}} +#endif + int v[1] = {1}; + std::random_shuffle(&v[0], &v[1]); + gen r; + std::random_shuffle(&v[0], &v[1], r); +} diff --git a/libcxx/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp b/libcxx/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp new file mode 100644 index 000000000000..7200b5626e18 --- /dev/null +++ b/libcxx/test/libcxx/depr/depr.auto.ptr/auto.ptr/auto_ptr.depr_in_cxx11.fail.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// +// +// template +// class auto_ptr; +// +// class auto_ptr; +// +// template +// class auto_ptr_ref; +// +// Deprecated in C++11 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR + +#include +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'auto_ptr' is deprecated}} + // expected-error@* 1 {{'auto_ptr' is deprecated}} + // expected-error@* 1 {{'auto_ptr_ref' is deprecated}} +#endif + typedef std::auto_ptr AP; + typedef std::auto_ptr APV; + typedef std::auto_ptr_ref APR; +} diff --git a/libcxx/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp b/libcxx/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp new file mode 100644 index 000000000000..cfbaae6012a3 --- /dev/null +++ b/libcxx/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.fail.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS + +#include +#include +#include "test_macros.h" + +int identity(int v) { return v; } +int sum(int a, int b) { return a + b; } + +struct Foo { + int const_zero() const { return 0; } + int const_identity(int v) const { return v; } + int zero() { return 0; } + int identity(int v) { return v; } +}; + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'pointer_to_unary_function' is deprecated}} + // expected-error@* 1 {{'pointer_to_binary_function' is deprecated}} + // expected-error@* 1 {{'ptr_fun' is deprecated}} + // expected-error@* 1 {{'ptr_fun' is deprecated}} + + // expected-error@* 1 {{'mem_fun_t' is deprecated}} + // expected-error@* 1 {{'mem_fun1_t' is deprecated}} + // expected-error@* 1 {{'const_mem_fun_t' is deprecated}} + // expected-error@* 1 {{'const_mem_fun1_t' is deprecated}} + // expected-error@* 2 {{'mem_fun' is deprecated}} + // expected-error@* 2 {{'mem_fun' is deprecated}} + + // expected-error@* 1 {{'mem_fun_ref_t' is deprecated}} + // expected-error@* 1 {{'mem_fun1_ref_t' is deprecated}} + // expected-error@* 1 {{'const_mem_fun_ref_t' is deprecated}} + // expected-error@* 1 {{'const_mem_fun1_ref_t' is deprecated}} + // expected-error@* 2 {{'mem_fun_ref' is deprecated}} + // expected-error@* 2 {{'mem_fun_ref' is deprecated}} +#endif + typedef std::pointer_to_unary_function PUF; + typedef std::pointer_to_binary_function PBF; + std::ptr_fun(identity); + std::ptr_fun(sum); + + typedef std::mem_fun_t MFT0; + typedef std::mem_fun1_t MFT1; + typedef std::const_mem_fun_t CMFT0; + typedef std::const_mem_fun1_t CMFT1; + std::mem_fun(&Foo::zero); + std::mem_fun(&Foo::identity); + std::mem_fun(&Foo::const_zero); + std::mem_fun(&Foo::const_identity); + + typedef std::mem_fun_ref_t MFR0; + typedef std::mem_fun1_ref_t MFR1; + typedef std::const_mem_fun_ref_t CMFR0; + typedef std::const_mem_fun1_ref_t CMFR1; + std::mem_fun_ref(&Foo::zero); + std::mem_fun_ref(&Foo::identity); + std::mem_fun_ref(&Foo::const_zero); + std::mem_fun_ref(&Foo::const_identity); +} diff --git a/libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.depr_in_cxx11.fail.cpp b/libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.depr_in_cxx11.fail.cpp new file mode 100644 index 000000000000..3688d8ba89e0 --- /dev/null +++ b/libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.depr_in_cxx11.fail.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. +// +//===----------------------------------------------------------------------===// + +// +// +// bind1st + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS + +#include + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'bind1st' is deprecated}} +#endif + std::bind1st(test_func(1), 5); +} diff --git a/libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.depr_in_cxx11.fail.cpp b/libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.depr_in_cxx11.fail.cpp new file mode 100644 index 000000000000..caf6d64b0ca1 --- /dev/null +++ b/libcxx/test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.depr_in_cxx11.fail.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. +// +//===----------------------------------------------------------------------===// + +// +// +// bind2nd + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS + +#include + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'bind2nd' is deprecated}} +#endif + std::bind2nd(test_func(1), 5); +} diff --git a/libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.depr_in_cxx11.fail.cpp b/libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.depr_in_cxx11.fail.cpp new file mode 100644 index 000000000000..49d4b0cb29e5 --- /dev/null +++ b/libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.depr_in_cxx11.fail.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. +// +//===----------------------------------------------------------------------===// + +// +// +// binder1st + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS + +#include + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'binder1st' is deprecated}} +#endif + typedef std::binder1st B1ST; +} diff --git a/libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.depr_in_cxx11.fail.cpp b/libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.depr_in_cxx11.fail.cpp new file mode 100644 index 000000000000..c8a86674c3fe --- /dev/null +++ b/libcxx/test/std/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.depr_in_cxx11.fail.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. +// +//===----------------------------------------------------------------------===// + +// +// +// binder2nd + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS + +#include + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'binder2nd' is deprecated}} +#endif + typedef std::binder2nd B2ND; +} diff --git a/libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.fail.cpp b/libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.fail.cpp new file mode 100644 index 000000000000..6ad3f7f3117b --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.fail.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// binary_negate +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include + +#include "test_macros.h" + +struct Predicate { + typedef int first_argument_type; + typedef int second_argument_type; + bool operator()(first_argument_type, second_argument_type) const { return true; } +}; + +int main() { +#if TEST_STD_VER < 17 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'binary_negate' is deprecated}} +#endif + std::binary_negate f((Predicate())); + (void)f; +} diff --git a/libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.fail.cpp b/libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.fail.cpp new file mode 100644 index 000000000000..a2f7f65b1c43 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.fail.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// not1 +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include + +#include "test_macros.h" + +struct Predicate { + typedef int argument_type; + bool operator()(argument_type) const { return true; } +}; + +int main() { +#if TEST_STD_VER < 17 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'not1' is deprecated}} +#endif + std::not1(Predicate()); +} diff --git a/libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.fail.cpp b/libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.fail.cpp new file mode 100644 index 000000000000..a858014596e9 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// not2 +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include + +#include "test_macros.h" + +struct Predicate { + typedef int first_argument_type; + typedef int second_argument_type; + bool operator()(first_argument_type, second_argument_type) const { return true; } +}; + +int main() { +#if TEST_STD_VER < 17 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'not2' is deprecated}} +#endif + std::not2(Predicate()); +} diff --git a/libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.fail.cpp b/libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.fail.cpp new file mode 100644 index 000000000000..3df852166fef --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// unary_negate +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include + +#include "test_macros.h" + +struct Predicate { + typedef int argument_type; + bool operator()(argument_type) const { return true; } +}; + +int main() { +#if TEST_STD_VER < 17 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'unary_negate' is deprecated}} +#endif + std::unary_negate f((Predicate())); + (void)f; +}