public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-10245] libstdc++: Add deprecated attribute to std::random_shuffle declarations Date: Mon, 18 Mar 2024 14:05:26 +0000 (GMT) [thread overview] Message-ID: <20240318140526.F35AE3858439@sourceware.org> (raw) https://gcc.gnu.org/g:bfa7e7dfc19e07bff319636cf1bdfd57b6c68f41 commit r12-10245-gbfa7e7dfc19e07bff319636cf1bdfd57b6c68f41 Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Jul 26 14:05:58 2023 +0100 libstdc++: Add deprecated attribute to std::random_shuffle declarations We already have these attributes on the definitions in <bits/stl_algo.h> but they don't work due to PR c++/84542. Add the attributes to the declarations in <bits/algorithmfwd.h> as well, and add a test. libstdc++-v3/ChangeLog: * include/bits/algorithmfwd.h (random_shuffle): Add deprecated attribute. * include/bits/stl_algo.h (random_shuffle): Correct comments. * testsuite/25_algorithms/random_shuffle/1.cc: Disable deprecated warnings. * testsuite/25_algorithms/random_shuffle/59603.cc: Likewise. * testsuite/25_algorithms/random_shuffle/moveable.cc: Likewise. * testsuite/25_algorithms/random_shuffle/deprecated.cc: New test. (cherry picked from commit c01b344e814001e07fd304ce98d013d811e90192) Diff: --- libstdc++-v3/include/bits/algorithmfwd.h | 2 ++ libstdc++-v3/include/bits/stl_algo.h | 4 ++-- .../testsuite/25_algorithms/random_shuffle/1.cc | 1 + .../testsuite/25_algorithms/random_shuffle/59603.cc | 1 + .../25_algorithms/random_shuffle/deprecated.cc | 18 ++++++++++++++++++ .../testsuite/25_algorithms/random_shuffle/moveable.cc | 1 + 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h index 5271a90b501..5b85b0bc60d 100644 --- a/libstdc++-v3/include/bits/algorithmfwd.h +++ b/libstdc++-v3/include/bits/algorithmfwd.h @@ -828,10 +828,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO partition(_BIter, _BIter, _Predicate); template<typename _RAIter> + _GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle") void random_shuffle(_RAIter, _RAIter); template<typename _RAIter, typename _Generator> + _GLIBCXX14_DEPRECATED_SUGGEST("std::shuffle") void random_shuffle(_RAIter, _RAIter, #if __cplusplus >= 201103L diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 1f07b9e6589..41a8cf2f3e1 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -4532,7 +4532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * equally likely. * * @deprecated - * Since C++14 `std::random_shuffle` is not part of the C++ standard. + * Since C++17, `std::random_shuffle` is not part of the C++ standard. * Use `std::shuffle` instead, which was introduced in C++11. */ template<typename _RandomAccessIterator> @@ -4572,7 +4572,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO * range [0,N). * * @deprecated - * Since C++14 `std::random_shuffle` is not part of the C++ standard. + * Since C++17, `std::random_shuffle` is not part of the C++ standard. * Use `std::shuffle` instead, which was introduced in C++11. */ template<typename _RandomAccessIterator, typename _RandomNumberGenerator> diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc index fd1f5eb0717..37814f695c6 100644 --- a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc @@ -15,6 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. +// { dg-options "-Wno-deprecated-declarations" } // { dg-add-options using-deprecated } // 25.2.11 random_shuffle() diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc index d5ef0725036..3a31dd12da0 100644 --- a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc @@ -16,6 +16,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do run { target c++11 } } +// { dg-options "-Wno-deprecated-declarations" } // { dg-add-options using-deprecated } // { dg-require-debug-mode "" } diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/deprecated.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/deprecated.cc new file mode 100644 index 00000000000..48fc5b029e7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/deprecated.cc @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-add-options using-deprecated } + +// std::random_shuffle was deprecated in C++17 and removed in C++17. + +#include <algorithm> + +std::ptrdiff_t rando(std::ptrdiff_t n); + +void +test_depr(int* first, int* last) +{ + std::random_shuffle(first, last); + // { dg-warning "deprecated" "" { target c++14 } 13 } + + std::random_shuffle(first, last, rando); + // { dg-warning "deprecated" "" { target c++14 } 16 } +} diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc index d72906828d0..18f6de40c69 100644 --- a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++11 } } +// { dg-options "-Wno-deprecated-declarations" } // { dg-add-options using-deprecated } // Copyright (C) 2009-2022 Free Software Foundation, Inc.
reply other threads:[~2024-03-18 14:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240318140526.F35AE3858439@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).