From patchwork Sat Nov 11 00:44:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 164046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp1498915vqs; Fri, 10 Nov 2023 17:57:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsPpjm9XTQX5aHWhXGv+iTUyHfSiAnMQSD57egHp6QsZMd++tnsTnBHzpeUv0UALsxind2 X-Received: by 2002:ac8:5ccb:0:b0:41e:ae5a:2b96 with SMTP id s11-20020ac85ccb000000b0041eae5a2b96mr1057863qta.13.1699667841019; Fri, 10 Nov 2023 17:57:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699667841; cv=pass; d=google.com; s=arc-20160816; b=zHMpg211gvGLD1TD/xo+q5LY8QgwJx2rL81YRzVgyKCGN2A+hvziupI0+I5l0mbTmC CuNuoYagv0XDmfEtkgdMSLhDr5G/ku1FIpgN1GAleFNzRTYZU2sYldg/dYQVrSDN1Hnw G6mck6ZlYxcxa8o7LsvMtTw8Sw6UlcKIUVkg9yEOlQ3sjgUTv4oF0oaOYd5x9KL5UyTt Gi8w7gEO5YtBwEr6Gq3+bfN1bysJ3xKoF1sATUBiwGWBjePEfyWT0/K6Bu432QwIOWTh zThcvXV924/vSnQ3yuzsvKPHvhX7Zt+ebL8Zo+ciVma86/VgNM0SyxxJ/cv7sOz1a1oC vqcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=EWHEL66+vXe+dsNmEzpIQQ7gDKb72G32xAmW5MJ1Ovo=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=K9djIaiwkxhsxAkoy6ocflcXZbtCwj1lu4kiAs0sVj0Kd0ih2KiU+QZRLQP1LRc0IY k4Y03h6I3XDDy+npvbR+ZVl9WFJHHG+gIRnt8p0Pe+UBMEtwbnzyrYF+AF4Mjk9UDXq6 OkengEEwKc1VCVKoDXwtfUKZqrsNeGSdfNx5KXZkWnfAzi1TTqJ5w/wLkR1rLW5p4eH6 BhbRzl8vWB3fPa6zYrFcANBVvTIJcfswPK5W1w+rwuKJnE0CWVqN2xj+3OcX4uHOVc6g laSpkkS/jGtjvk9rBCdbfx7L2WGPJ7OygzM9lOBqrf+rzBYnvrnoy1Y+3cmkFdJDLGs0 j/DA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eJ2k1lxj; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w14-20020ac87e8e000000b0041812c64682si682214qtj.112.2023.11.10.17.57.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 17:57:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eJ2k1lxj; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A8073954419 for ; Sat, 11 Nov 2023 00:46:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 5EF553889E07 for ; Sat, 11 Nov 2023 00:44:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5EF553889E07 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5EF553889E07 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699663498; cv=none; b=IDDQjxRQt0LqSbwDMb5HS1i4WWgrxH17KYEMFPZvJf4DxvtarSlN23uuZzcFN7Hj19hoSyu5BEGkMjghwoVZdpcF3frSW88Bb/mCcbvVDyJQtH2MmNG03xRQvGC88aBjlws21JL/YSC2Xw3XfxRVTR3nj691D0cpVbxcnW1RpbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699663498; c=relaxed/simple; bh=usw5+Edv/qeth/7DRf84og5oTWrN5Cyo2SB0kVT36nk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LrJDaegW3qe9fGhsr12KX8u9B0M+RS3qt8fYYIG9MKEo4IxFr4fc6R7Nyk0FM2S603et8aqAvPg55sJ/W6A45AG+WOzPy/Q1cY38skkxo+duDJbqqtjsuDmyIlVJqQl8+qXI9YfJZ2PDu982CpwPynLCwPQik7cFFDQ7v7P607E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699663496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EWHEL66+vXe+dsNmEzpIQQ7gDKb72G32xAmW5MJ1Ovo=; b=eJ2k1lxj0Ox897Ar2aYhPsGaa9RrHyPbkPvyNz/FsZeOtTz64rvzVOlGBBqacUugDo77sF rdOJ3Rz4W+qk0q7QjcOg7rRPEpdgb4QGyVryfWsu1wab6ada5vB/euIXsPxDchG8kVPHsx XRBL8srAxd3yUgIyNkEYgQlTuklFiYQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-WUM132sNNvC7eyy_xhG99Q-1; Fri, 10 Nov 2023 19:44:54 -0500 X-MC-Unique: WUM132sNNvC7eyy_xhG99Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46AE880C343; Sat, 11 Nov 2023 00:44:54 +0000 (UTC) Received: from localhost (unknown [10.42.28.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F36F2166B26; Sat, 11 Nov 2023 00:44:53 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Deprecate std::atomic_xxx overloads for std::shared_ptr Date: Sat, 11 Nov 2023 00:44:47 +0000 Message-ID: <20231111004453.78040-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782230905557269226 X-GMAIL-MSGID: 1782230905557269226 Tested x86_64-linux. Pushed to trunk. -- >8 -- These overloads are deprecated in C++20 (and likely to be removed for C++26). The std::atomic> specialization should be preferred in new code. libstdc++-v3/ChangeLog: * include/bits/shared_ptr_atomic.h (atomic_is_lock_free) (atomic_load_explicit, atomic_load, atomic_store_explicit) (atomic_store, atomic_exchange_explicit, atomic_exchange) (atomic_compare_exchange_strong, atomic_compare_exchange_weak) (atomic_compare_exchange_strong_explicit) (atomic_compare_exchange_weak_explicit): Add deprecated attribute for C++20 and later. * testsuite/20_util/shared_ptr/atomic/1.cc: Suppress deprecated warnings. * testsuite/20_util/shared_ptr/atomic/2.cc: Likewise. * testsuite/20_util/shared_ptr/atomic/3.cc: Likewise. * testsuite/29_atomics/atomic/lwg3220.cc: Likewise. --- libstdc++-v3/include/bits/shared_ptr_atomic.h | 22 +++++++++++++++++++ .../testsuite/20_util/shared_ptr/atomic/1.cc | 1 + .../testsuite/20_util/shared_ptr/atomic/2.cc | 1 + .../testsuite/20_util/shared_ptr/atomic/3.cc | 1 + .../testsuite/29_atomics/atomic/lwg3220.cc | 1 + 5 files changed, 26 insertions(+) diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h b/libstdc++-v3/include/bits/shared_ptr_atomic.h index ae2d1b7a094..5b818fe4456 100644 --- a/libstdc++-v3/include/bits/shared_ptr_atomic.h +++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h @@ -101,6 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_is_lock_free(const __shared_ptr<_Tp, _Lp>*) { @@ -112,6 +113,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_is_lock_free(const shared_ptr<_Tp>* __p) { return std::atomic_is_lock_free<_Tp, __default_lock_policy>(__p); } @@ -128,6 +130,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline shared_ptr<_Tp> atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) { @@ -136,11 +139,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline shared_ptr<_Tp> atomic_load(const shared_ptr<_Tp>* __p) { return std::atomic_load_explicit(__p, memory_order_seq_cst); } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline __shared_ptr<_Tp, _Lp> atomic_load_explicit(const __shared_ptr<_Tp, _Lp>* __p, memory_order) { @@ -149,6 +154,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline __shared_ptr<_Tp, _Lp> atomic_load(const __shared_ptr<_Tp, _Lp>* __p) { return std::atomic_load_explicit(__p, memory_order_seq_cst); } @@ -164,6 +170,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline void atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) @@ -173,11 +180,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline void atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline void atomic_store_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r, @@ -188,6 +197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline void atomic_store(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) { std::atomic_store_explicit(__p, std::move(__r), memory_order_seq_cst); } @@ -201,6 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline shared_ptr<_Tp> atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) @@ -211,6 +222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline shared_ptr<_Tp> atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) { @@ -219,6 +231,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline __shared_ptr<_Tp, _Lp> atomic_exchange_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r, @@ -230,6 +243,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline __shared_ptr<_Tp, _Lp> atomic_exchange(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r) { @@ -250,6 +264,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") bool atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, @@ -272,6 +287,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) @@ -281,6 +297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, @@ -293,6 +310,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) @@ -302,6 +320,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") bool atomic_compare_exchange_strong_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, @@ -324,6 +343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_compare_exchange_strong(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, @@ -334,6 +354,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_compare_exchange_weak_explicit(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, @@ -346,6 +367,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template + _GLIBCXX20_DEPRECATED_SUGGEST("std::atomic>") inline bool atomic_compare_exchange_weak(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp>* __v, diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/1.cc index e9fb8d0f329..b5225f8a0df 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/1.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/1.cc @@ -18,6 +18,7 @@ // { dg-do run { target c++11 } } // { dg-require-gthreads "" } // { dg-require-effective-target hosted } +// { dg-additional-options "-Wno-deprecated" { target c++20 } } #include diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/2.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/2.cc index 778f132d33a..f8412fe1eb1 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/2.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/2.cc @@ -18,6 +18,7 @@ // { dg-do run { target c++11 } } // { dg-require-gthreads "" } // { dg-require-effective-target hosted } +// { dg-additional-options "-Wno-deprecated" { target c++20 } } #include diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc index 19efcadb7ec..6c5bad1e094 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc @@ -1,6 +1,7 @@ // { dg-do run { target c++11 } } // { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } +// { dg-additional-options "-Wno-deprecated" { target c++20 } } // Copyright (C) 2014-2023 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc b/libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc index ba289e197dc..217db7cbfea 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/lwg3220.cc @@ -1,3 +1,4 @@ +// { dg-options "-Wno-deprecated" } // { dg-do compile { target c++11 } } // std::shared_ptr is not freestanding.