]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Deprecate std::rel_ops namespace for C++20
authorJonathan Wakely <jwakely@redhat.com>
Wed, 27 Nov 2024 23:36:03 +0000 (23:36 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 28 Nov 2024 15:27:28 +0000 (15:27 +0000)
This is deprecated in the C++20 standard and will be removed at some
point.

libstdc++-v3/ChangeLog:

* include/bits/stl_relops.h (rel_ops): Add deprecated attribute.
* testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc:
Add dg-warning for -Wdeprecated warnings.
* testsuite/20_util/rel_ops.cc: Likewise.
* testsuite/util/testsuite_containers.h: Disable -Wdeprecated
warnings when using rel_ops.

libstdc++-v3/include/bits/stl_relops.h
libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc
libstdc++-v3/testsuite/20_util/rel_ops.cc
libstdc++-v3/testsuite/util/testsuite_containers.h

index 06c85ca8da91d67488b1db287ed9774b87d8dd07..29e7af3c2504e5759c1977802122df486d74a67a 100644 (file)
@@ -63,7 +63,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  namespace rel_ops
+  namespace rel_ops _GLIBCXX20_DEPRECATED_SUGGEST("<=>")
   {
     /** @namespace std::rel_ops
      *  @brief  The generated relational operators are sequestered here.
index 330bde88d63e03a1d577e1a2c4f43e80702d12b2..b583eaa4713cedceced80b6f3eaa87762ea6086e 100644 (file)
@@ -21,5 +21,5 @@
 
 namespace gnu
 {
-  using namespace std::rel_ops;
+  using namespace std::rel_ops; // { dg-warning "deprecated" "" { target c++20 } }
 }
index 711822966d3a5a6aea22a1de9350cfa6d0f7d8df..f84503293e1badda3bcc0b5d2a30079a4c6bcd75 100644 (file)
@@ -24,7 +24,7 @@
 #include <utility>
 #include <vector>
 
-using namespace std::rel_ops;
+using namespace std::rel_ops; // { dg-warning "deprecated" "" { target c++20 } }
 
 // libstdc++/3628
 void test01()
index 4dd78d4ec9d7b0a6a6ae2a111e0450235f746afc..f48bb54f140a78fab74b75b7b4c347ccfaaf7172 100644 (file)
@@ -183,9 +183,12 @@ namespace __gnu_test
     {
       forward_members_unordered(const typename _Tp::value_type& v)
       {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
        // Make sure that even if rel_ops is injected there is no ambiguity
        // when comparing iterators.
        using namespace std::rel_ops;
+#pragma GCC diagnostic pop
 
        typedef _Tp                                     test_type;
        test_type container;
@@ -283,9 +286,12 @@ namespace __gnu_test
     {
       forward_members(_Tp& container)
       {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
        // Make sure that even if rel_ops is injected there is no ambiguity
        // when comparing iterators.
        using namespace std::rel_ops;
+#pragma GCC diagnostic pop
 
        typedef traits<_Tp> traits_type;
        iterator_concept_checks<typename _Tp::iterator,
@@ -318,9 +324,12 @@ namespace __gnu_test
       category_members(_Tp& container)
        : forward_members<_Tp>(container)
       {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
        // Make sure that even if rel_ops is injected there is no ambiguity
        // when comparing iterators.
        using namespace std::rel_ops;
+#pragma GCC diagnostic pop
 
        assert( !(container.begin() < container.begin()) );
        assert( !(container.cbegin() < container.cbegin()) );