From patchwork Wed Mar 18 13:00:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1257480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=kBFFMmK8; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48j9BC4b0Wz9sQt for ; Thu, 19 Mar 2020 00:00:17 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C16CF3944438; Wed, 18 Mar 2020 13:00:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C16CF3944438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584536415; bh=PYohJixwj9sJwGbbx2ALZzQQ7ik0kRK3+8IsukX5g2U=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kBFFMmK8iL5CEeYzHaV2iEykgHXA4YheEDxJUU6RokThfa2B73yI39HwIOuO5u/bv zBGYIsPjdQy7Epk1oGdwWTDhgwv1hQ8qZC8DMU2lhKs2KpBrMqZcpU3BLcj3XJ8Zxs aD+3S34+xTca1MOeZVNdsTtunYOkTxqis4XDL94s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by sourceware.org (Postfix) with ESMTP id 0655C393FC2D for ; Wed, 18 Mar 2020 13:00:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0655C393FC2D 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-383-CAoGIhfvMZSaBCHgArhggg-1; Wed, 18 Mar 2020 09:00:09 -0400 X-MC-Unique: CAoGIhfvMZSaBCHgArhggg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0433189F76C; Wed, 18 Mar 2020 13:00:08 +0000 (UTC) Received: from localhost (unknown [10.33.36.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 261575E25A; Wed, 18 Mar 2020 13:00:07 +0000 (UTC) Date: Wed, 18 Mar 2020 13:00:07 +0000 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 1/2] libstdc++: Fix compilation with released versions of Clang Message-ID: <20200318130007.GA3999072@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-25.2 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Clang 9 supports C++20 via -std=c++2a but doesn't support Concepts, so several of the new additions related to the Ranges library fail to compile with -std=c++2a. The new definition of iterator_traits and the definition of default_sentinel_t are guarded by __cpp_lib_concepts, so check that in addition to __cplusplus > 201703L. * include/bits/stl_algobase.h (__lexicographical_compare_aux): Check __cpp_lib_concepts before using iter_reference_t. * include/bits/stream_iterator.h (istream_iterator): Check __cpp_lib_concepts before using default_sentinel_t. * include/bits/streambuf_iterator.h (istreambuf_iterator): Likewise. Tested powerpc64le-linux, committed to master. commit 07522ae90b5bae2ca95b64f3a4de60bea0cc0567 Author: Jonathan Wakely Date: Wed Mar 18 12:55:29 2020 +0000 libstdc++: Fix compilation with released versions of Clang Clang 9 supports C++20 via -std=c++2a but doesn't support Concepts, so several of the new additions related to the Ranges library fail to compile with -std=c++2a. The new definition of iterator_traits and the definition of default_sentinel_t are guarded by __cpp_lib_concepts, so check that in addition to __cplusplus > 201703L. * include/bits/stl_algobase.h (__lexicographical_compare_aux): Check __cpp_lib_concepts before using iter_reference_t. * include/bits/stream_iterator.h (istream_iterator): Check __cpp_lib_concepts before using default_sentinel_t. * include/bits/streambuf_iterator.h (istreambuf_iterator): Likewise. diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 8f3ca885f03..a7e92d4b473 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -1283,7 +1283,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed && __is_pointer<_II1>::__value && __is_pointer<_II2>::__value -#if __cplusplus > 201703L +#if __cplusplus > 201703L && __cpp_lib_concepts // For C++20 iterator_traits::value_type is non-volatile // so __is_byte could be true, but we can't use memcmp with // volatile data. diff --git a/libstdc++-v3/include/bits/stream_iterator.h b/libstdc++-v3/include/bits/stream_iterator.h index 9d8ead092b8..bd5ba2a80c0 100644 --- a/libstdc++-v3/include/bits/stream_iterator.h +++ b/libstdc++-v3/include/bits/stream_iterator.h @@ -77,7 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_ok(__obj._M_ok) { } -#if __cplusplus > 201703L +#if __cplusplus > 201703L && __cpp_lib_concepts constexpr istream_iterator(default_sentinel_t) noexcept(is_nothrow_default_constructible_v<_Tp>) @@ -153,7 +153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator!=(const istream_iterator& __x, const istream_iterator& __y) { return !__x._M_equal(__y); } -#if __cplusplus > 201703L +#if __cplusplus > 201703L && __cpp_lib_concepts friend bool operator==(const istream_iterator& __i, default_sentinel_t) { return !__i._M_stream; } diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h index fc06c50040c..d3f1610fc8d 100644 --- a/libstdc++-v3/include/bits/streambuf_iterator.h +++ b/libstdc++-v3/include/bits/streambuf_iterator.h @@ -115,7 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_CONSTEXPR istreambuf_iterator() _GLIBCXX_USE_NOEXCEPT : _M_sbuf(0), _M_c(traits_type::eof()) { } -#if __cplusplus > 201703L +#if __cplusplus > 201703L && __cpp_lib_concepts constexpr istreambuf_iterator(default_sentinel_t) noexcept : istreambuf_iterator() { } #endif @@ -215,7 +215,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return traits_type::eq_int_type(__c, __eof); } -#if __cplusplus > 201703L +#if __cplusplus > 201703L && __cpp_lib_concepts friend bool operator==(const istreambuf_iterator& __i, default_sentinel_t __s) { return __i._M_at_eof(); } From patchwork Wed Mar 18 13:01:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1257482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=PbdREMao; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48j9DG1z1Kz9sSt for ; Thu, 19 Mar 2020 00:02:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 667853944416; Wed, 18 Mar 2020 13:02:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 667853944416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584536523; bh=zCRuTkqFnvnQghw8NQOUtczW723ZYBe9hmv23U0Gh9c=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PbdREMaoElj0/JZOStEOnq69WDQ6K4mhI/4iTEXrt8S5HUtUS2Ij1NPo2emFB9bKr mBc63O1mCluBdqHeLfQx096ETGojUSCG2e46JXWpUcj7daLKFOhWTvvLAj4wXeiGwE SDxOG1tYgqhQ57lYzu+afeU8O0gLtiToTfG0Jbdc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by sourceware.org (Postfix) with ESMTP id A988E3944438 for ; Wed, 18 Mar 2020 13:02:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A988E3944438 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-270-qmuEvlgDPl-G8JJVuQTocg-1; Wed, 18 Mar 2020 09:01:59 -0400 X-MC-Unique: qmuEvlgDPl-G8JJVuQTocg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E967D108839E; Wed, 18 Mar 2020 13:01:57 +0000 (UTC) Received: from localhost (unknown [10.33.36.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A7F15F923; Wed, 18 Mar 2020 13:01:38 +0000 (UTC) Date: Wed, 18 Mar 2020 13:01:37 +0000 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 2/2] libstdc++: Fix compilation of with Clang Message-ID: <20200318130137.GO9441@redhat.com> References: <20200318130007.GA3999072@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200318130007.GA3999072@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-25.2 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Clang 9 supports C++20 via -std=c++2a but doesn't support three-way comparisons, so fails to compile. When the compiler doesn't support default comparisons, this patch defines operator== and operator!= for the _Stop_state_ref class. That is enough for the header to be compiled with Clang. It allows operator== for stop_token and stop_source to work, but not operator!= because that isn't explicitly defined. * include/std/stop_token (stop_token::_Stop_state_ref): Define comparison operators explicitly if the compiler won't synthesize them. Tested powerpc64le-linux, committed to master. commit e5de406f9967ef4b0bbdbcbc0320869d2bf04558 Author: Jonathan Wakely Date: Wed Mar 18 12:55:29 2020 +0000 libstdc++ Fix compilation of with Clang Clang 9 supports C++20 via -std=c++2a but doesn't support three-way comparisons, so fails to compile. When the compiler doesn't support default comparisons, this patch defines operator== and operator!= for the _Stop_state_ref class. That is enough for the header to be compiled with Clang. It allows operator== for stop_token and stop_source to work, but not operator!= because that isn't explicitly defined. * include/std/stop_token (stop_token::_Stop_state_ref): Define comparison operators explicitly if the compiler won't synthesize them. diff --git a/libstdc++-v3/include/std/stop_token b/libstdc++-v3/include/std/stop_token index 6fb8ae05197..87beb08c71d 100644 --- a/libstdc++-v3/include/std/stop_token +++ b/libstdc++-v3/include/std/stop_token @@ -456,8 +456,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Stop_state_t* operator->() const noexcept { return _M_ptr; } +#if __cpp_impl_three_way_comparison >= 201907L friend bool operator==(const _Stop_state_ref&, const _Stop_state_ref&) = default; +#else + friend bool + operator==(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs) + noexcept + { return __lhs._M_ptr == __rhs._M_ptr; } + + friend bool + operator!=(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs) + noexcept + { return __lhs._M_ptr != __rhs._M_ptr; } +#endif private: _Stop_state_t* _M_ptr = nullptr;