From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 573F6398305F for ; Tue, 27 Jul 2021 12:16:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 573F6398305F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-7LquwQFjO5WTOnkTFh3emg-1; Tue, 27 Jul 2021 08:16:43 -0400 X-MC-Unique: 7LquwQFjO5WTOnkTFh3emg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62400190A7AF; Tue, 27 Jul 2021 12:16:42 +0000 (UTC) Received: from localhost (ovpn-113-85.ams2.redhat.com [10.36.113.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id D525E18432; Tue, 27 Jul 2021 12:16:41 +0000 (UTC) Date: Tue, 27 Jul 2021 13:16:40 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] [2/2] libstdc++: Remove unnecessary uses of Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="ImRTvRYTCKSG2fqP" Content-Disposition: inline X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jul 2021 12:16:51 -0000 --ImRTvRYTCKSG2fqP Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline The header includes , with a comment referring to UK-300, a National Body comment on the C++11 draft. That comment proposed to move std::swap to and then require to include . The comment was rejected, so we do not need to implement the suggestion. For backwards compatibility with C++03 we do want to define std::swap, but it does so anyway via . We don't need the whole of to do that. A few other headers that need std::swap can include to get it, instead of . There are several headers that include to get std::pair, but they can use to get it without also including the rel_ops namespace and other contents of . Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/std/algorithm: Do not include . * include/std/functional: Likewise. * include/std/regex: Include instead of . * include/debug/map.h: Likewise. * include/debug/multimap.h: Likewise. * include/debug/multiset.h: Likewise. * include/debug/set.h: Likewise. * include/debug/vector: Likewise. * include/bits/fs_path.h: Likewise. * include/bits/unique_ptr.h: Do not include . * include/experimental/any: Likewise. * include/experimental/executor: Likewise. * include/experimental/memory: Likewise. * include/experimental/optional: Likewise. * include/experimental/socket: Use __exchange instead of std::exchange. * src/filesystem/ops-common.h: Likewise. * testsuite/20_util/default_delete/48631_neg.cc: Adjust expected errors to not use a hardcoded line number. * testsuite/20_util/default_delete/void_neg.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc: Include for std::as_const. * testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc: Likewise. * testsuite/23_containers/vector/cons/destructible_debug_neg.cc: Adjust dg-error line number. Tested powerpc64le-linux. Committed to trunk. --ImRTvRYTCKSG2fqP Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 16158c96496b537194111526d25e19f268d613b6 Author: Jonathan Wakely Date: Thu Jul 22 14:48:27 2021 libstdc++: Remove unnecessary uses of The header includes , with a comment referring to UK-300, a National Body comment on the C++11 draft. That comment proposed to move std::swap to and then require to include . The comment was rejected, so we do not need to implement the suggestion. For backwards compatibility with C++03 we do want to define std::swap, but it does so anyway via . We don't need the whole of to do that. A few other headers that need std::swap can include to get it, instead of . There are several headers that include to get std::pair, but they can use to get it without also including the rel_ops namespace and other contents of . Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/std/algorithm: Do not include . * include/std/functional: Likewise. * include/std/regex: Include instead of . * include/debug/map.h: Likewise. * include/debug/multimap.h: Likewise. * include/debug/multiset.h: Likewise. * include/debug/set.h: Likewise. * include/debug/vector: Likewise. * include/bits/fs_path.h: Likewise. * include/bits/unique_ptr.h: Do not include . * include/experimental/any: Likewise. * include/experimental/executor: Likewise. * include/experimental/memory: Likewise. * include/experimental/optional: Likewise. * include/experimental/socket: Use __exchange instead of std::exchange. * src/filesystem/ops-common.h: Likewise. * testsuite/20_util/default_delete/48631_neg.cc: Adjust expected errors to not use a hardcoded line number. * testsuite/20_util/default_delete/void_neg.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc: Include for std::as_const. * testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc: Likewise. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc: Likewise. * testsuite/23_containers/vector/cons/destructible_debug_neg.cc: Adjust dg-error line number. diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 4fcd1def92f..3151af1e901 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -32,7 +32,6 @@ #if __cplusplus >= 201703L -#include #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 0a0667a7608..2d8b9ed3fae 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index ab34b2affd9..c0153d09abe 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index 96a44f4725f..94929344a9d 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index 0e76c5ff332..bb68d8c8f18 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index c579de7426d..cdf35ea5396 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 987bba17c2b..79ccf527dd6 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -37,7 +37,6 @@ namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { } } // namespace std::__debug #include -#include #include #include #include diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index 3bb3e8c4a0a..7d18f267e8b 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -36,8 +36,8 @@ #include #include -#include #include +#include #include namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor index c670f2739b6..4322a7f5caf 100644 --- a/libstdc++-v3/include/experimental/executor +++ b/libstdc++-v3/include/experimental/executor @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/libstdc++-v3/include/experimental/memory b/libstdc++-v3/include/experimental/memory index a74b2402f7a..a89a5ecfa84 100644 --- a/libstdc++-v3/include/experimental/memory +++ b/libstdc++-v3/include/experimental/memory @@ -40,7 +40,6 @@ #include #include -#include #include #include diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional index ae2418f0500..431d23631cf 100644 --- a/libstdc++-v3/include/experimental/optional +++ b/libstdc++-v3/include/experimental/optional @@ -32,7 +32,6 @@ #if __cplusplus >= 201402L -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include #include namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/experimental/socket b/libstdc++-v3/include/experimental/socket index 9db4a245ccf..6d1c114254a 100644 --- a/libstdc++-v3/include/experimental/socket +++ b/libstdc++-v3/include/experimental/socket @@ -429,16 +429,16 @@ inline namespace v1 __socket_impl(__socket_impl&& __rhs) : _M_ctx(__rhs._M_ctx), - _M_sockfd(std::exchange(__rhs._M_sockfd, -1)), - _M_bits(std::exchange(__rhs._M_bits, {})) + _M_sockfd(std::__exchange(__rhs._M_sockfd, -1)), + _M_bits(std::__exchange(__rhs._M_bits, {})) { } __socket_impl& operator=(__socket_impl&& __rhs) { _M_ctx = __rhs._M_ctx; - _M_sockfd = std::exchange(__rhs._M_sockfd, -1); - _M_bits = std::exchange(__rhs._M_bits, {}); + _M_sockfd = std::__exchange(__rhs._M_sockfd, -1); + _M_bits = std::__exchange(__rhs._M_bits, {}); return *this; } @@ -615,7 +615,7 @@ inline namespace v1 { __glibcxx_assert(is_open()); cancel(__ec); - return std::exchange(_M_sockfd, -1); + return std::__exchange(_M_sockfd, -1); } template diff --git a/libstdc++-v3/include/std/algorithm b/libstdc++-v3/include/std/algorithm index 9ce4aa8423d..c9df7eae1ff 100644 --- a/libstdc++-v3/include/std/algorithm +++ b/libstdc++-v3/include/std/algorithm @@ -57,7 +57,6 @@ #pragma GCC system_header -#include // UK-300. #include #include #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index f61f2ac8cfd..131e6629341 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -61,7 +61,6 @@ # include # include # include -# include # include #endif #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex index cd33f26af0d..e623a6ed498 100644 --- a/libstdc++-v3/include/std/regex +++ b/libstdc++-v3/include/std/regex @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -55,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/libstdc++-v3/src/filesystem/ops-common.h b/libstdc++-v3/src/filesystem/ops-common.h index 529d4e09016..43311e6c38f 100644 --- a/libstdc++-v3/src/filesystem/ops-common.h +++ b/libstdc++-v3/src/filesystem/ops-common.h @@ -26,6 +26,7 @@ #define _GLIBCXX_OPS_COMMON_H 1 #include +#include // std::__exchange #ifdef _GLIBCXX_HAVE_UNISTD_H # include @@ -407,7 +408,7 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM struct CloseFD { ~CloseFD() { if (fd != -1) posix::close(fd); } - bool close() { return posix::close(std::exchange(fd, -1)) == 0; } + bool close() { return posix::close(std::__exchange(fd, -1)) == 0; } int fd; }; diff --git a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc index 5de981665d9..3e80b73603e 100644 --- a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc +++ b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc @@ -26,4 +26,4 @@ struct D : B { }; D d; std::default_delete db; typedef decltype(db(&d)) type; // { dg-error "no match" } -// { dg-error "no type" "" { target *-*-* } 116 } +// { dg-prune-output "no type named 'type' in 'struct std::enable_if" } diff --git a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc index 217c39b5eb4..ac4eabc5341 100644 --- a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc +++ b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc @@ -25,5 +25,5 @@ void test01() { std::default_delete d; d(nullptr); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 81 } + // { dg-error "delete pointer to incomplete type" "" { target *-*-* } 0 } } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc index ac9128e6a00..7946effcf3a 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc index 05824c021a8..7267738a4af 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc index cc8cf0beef8..8759d042bb6 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc index efcf138dd5f..164d9ca667b 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc index 2283d99b260..b85199e693f 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc @@ -46,7 +46,7 @@ test02() // { dg-error "value type is destructible" "" { target *-*-* } 0 } // In Debug Mode the "required from here" errors come from -// { dg-error "required from here" "" { target *-*-* } 173 } +// { dg-error "required from here" "" { target *-*-* } 172 } // Needed because of PR c++/92193 // { dg-prune-output "deleted function" } --ImRTvRYTCKSG2fqP--