diff options
author | Louis Dionne <ldionne@apple.com> | 2018-09-23 18:35:00 +0000 |
---|---|---|
committer | Louis Dionne <ldionne@apple.com> | 2018-09-23 18:35:00 +0000 |
commit | ea5cd3b4760ebe1b0ad4469aa9ba221e00795c51 (patch) | |
tree | 9c7905f4a666a957d0e4e88fb734da604a61012d /libcxx/test | |
parent | 19952add7cea53050ee9b80b99494ebc00acefda (diff) | |
download | bcm5719-llvm-ea5cd3b4760ebe1b0ad4469aa9ba221e00795c51.tar.gz bcm5719-llvm-ea5cd3b4760ebe1b0ad4469aa9ba221e00795c51.zip |
[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()
<rdar://problem/18168350>
Reviewers: mclow.lists, EricWF
Subscribers: christof, dexonsmith, llvm-commits
Differential Revision: https://reviews.llvm.org/D48912
llvm-svn: 342843
Diffstat (limited to 'libcxx/test')
12 files changed, 464 insertions, 1 deletions
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 28a9281b49c..58ce689981c 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 @@ // //===----------------------------------------------------------------------===// -// <memory> +// <algorithm> // template <class RandomAccessIterator> // void @@ -23,6 +23,8 @@ // However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE // is defined before including <algorithm>, 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 00000000000..cf9925bc326 --- /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. +// +//===----------------------------------------------------------------------===// + +// <algorithm> + +// template <class RandomAccessIterator> +// void +// random_shuffle(RandomAccessIterator first, RandomAccessIterator last); +// +// template <class RandomAccessIterator, class RandomNumberGenerator> +// 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 <algorithm> +#include <cstddef> + +#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<int *>' is deprecated}} + // expected-error@* 1 {{'random_shuffle<int *, gen &>' 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 00000000000..7200b5626e1 --- /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. +// +//===----------------------------------------------------------------------===// + +// <memory> +// +// template <class X> +// class auto_ptr; +// +// class auto_ptr<void>; +// +// template <class X> +// 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 <memory> +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'auto_ptr<int>' is deprecated}} + // expected-error@* 1 {{'auto_ptr<void>' is deprecated}} + // expected-error@* 1 {{'auto_ptr_ref<int>' is deprecated}} +#endif + typedef std::auto_ptr<int> AP; + typedef std::auto_ptr<void> APV; + typedef std::auto_ptr_ref<int> 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 00000000000..cfbaae6012a --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// 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 <functional> +#include <cassert> +#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<int, int>' is deprecated}} + // expected-error@* 1 {{'pointer_to_binary_function<int, int, int>' is deprecated}} + // expected-error@* 1 {{'ptr_fun<int, int>' is deprecated}} + // expected-error@* 1 {{'ptr_fun<int, int, int>' is deprecated}} + + // expected-error@* 1 {{'mem_fun_t<int, Foo>' is deprecated}} + // expected-error@* 1 {{'mem_fun1_t<int, Foo, int>' is deprecated}} + // expected-error@* 1 {{'const_mem_fun_t<int, Foo>' is deprecated}} + // expected-error@* 1 {{'const_mem_fun1_t<int, Foo, int>' is deprecated}} + // expected-error@* 2 {{'mem_fun<int, Foo>' is deprecated}} + // expected-error@* 2 {{'mem_fun<int, Foo, int>' is deprecated}} + + // expected-error@* 1 {{'mem_fun_ref_t<int, Foo>' is deprecated}} + // expected-error@* 1 {{'mem_fun1_ref_t<int, Foo, int>' is deprecated}} + // expected-error@* 1 {{'const_mem_fun_ref_t<int, Foo>' is deprecated}} + // expected-error@* 1 {{'const_mem_fun1_ref_t<int, Foo, int>' is deprecated}} + // expected-error@* 2 {{'mem_fun_ref<int, Foo>' is deprecated}} + // expected-error@* 2 {{'mem_fun_ref<int, Foo, int>' is deprecated}} +#endif + typedef std::pointer_to_unary_function<int, int> PUF; + typedef std::pointer_to_binary_function<int, int, int> PBF; + std::ptr_fun<int, int>(identity); + std::ptr_fun<int, int, int>(sum); + + typedef std::mem_fun_t<int, Foo> MFT0; + typedef std::mem_fun1_t<int, Foo, int> MFT1; + typedef std::const_mem_fun_t<int, Foo> CMFT0; + typedef std::const_mem_fun1_t<int, Foo, int> CMFT1; + std::mem_fun<int, Foo>(&Foo::zero); + std::mem_fun<int, Foo, int>(&Foo::identity); + std::mem_fun<int, Foo>(&Foo::const_zero); + std::mem_fun<int, Foo, int>(&Foo::const_identity); + + typedef std::mem_fun_ref_t<int, Foo> MFR0; + typedef std::mem_fun1_ref_t<int, Foo, int> MFR1; + typedef std::const_mem_fun_ref_t<int, Foo> CMFR0; + typedef std::const_mem_fun1_ref_t<int, Foo, int> CMFR1; + std::mem_fun_ref<int, Foo>(&Foo::zero); + std::mem_fun_ref<int, Foo, int>(&Foo::identity); + std::mem_fun_ref<int, Foo>(&Foo::const_zero); + std::mem_fun_ref<int, Foo, int>(&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 00000000000..3688d8ba89e --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> +// +// 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 <functional> + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'bind1st<test_func, int>' 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 00000000000..caf6d64b0ca --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> +// +// 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 <functional> + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'bind2nd<test_func, int>' 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 00000000000..49d4b0cb29e --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> +// +// 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 <functional> + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'binder1st<test_func>' is deprecated}} +#endif + typedef std::binder1st<test_func> 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 00000000000..c8a86674c3f --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> +// +// 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 <functional> + +#include "../test_func.h" +#include "test_macros.h" + +int main() +{ +#if TEST_STD_VER < 11 + // expected-no-diagnostics +#else + // expected-error@* 1 {{'binder2nd<test_func>' is deprecated}} +#endif + typedef std::binder2nd<test_func> 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 00000000000..6ad3f7f3117 --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// binary_negate +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include <functional> + +#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<Predicate>' is deprecated}} +#endif + std::binary_negate<Predicate> 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 00000000000..a2f7f65b1c4 --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// not1 +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include <functional> + +#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<Predicate>' 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 00000000000..a858014596e --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// not2 +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include <functional> + +#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<Predicate>' 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 00000000000..3df852166fe --- /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. +// +//===----------------------------------------------------------------------===// + +// <functional> + +// unary_negate +// deprecated in C++17 + +// REQUIRES: verify-support + +// MODULES_DEFINES: _LIBCPP_ENABLE_DEPRECATION_WARNINGS +#define _LIBCPP_ENABLE_DEPRECATION_WARNINGS + +#include <functional> + +#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<Predicate>' is deprecated}} +#endif + std::unary_negate<Predicate> f((Predicate())); + (void)f; +} |