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.129.124]) by sourceware.org (Postfix) with ESMTPS id CAD7D385843E for ; Thu, 2 Feb 2023 17:39:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAD7D385843E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675359548; 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=IoCFUh3hEJdXfOVI8bVW2B+lcyTaYFoqE/cRO/QphZs=; b=iMRWafmgKZTqbUtX0TZi6A7MlUnborY5OZxy0CVxHVePcAJNDPt3IkfTlpbnO9lBZEpui7 4F8PkCBGhKLSrbtHgBTD3EN0mGCbVyVhYL5F4oPKdioYN3o49tugi6PujkNUDHT8jd34Dl J4wdFsRtfCUKmuimV/djJ6vQXBEhw8k= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-KKG4WBK9PumSz6UZmbKzLw-1; Thu, 02 Feb 2023 12:39:05 -0500 X-MC-Unique: KKG4WBK9PumSz6UZmbKzLw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AECBE280605E; Thu, 2 Feb 2023 17:39:04 +0000 (UTC) Received: from localhost (unknown [10.33.36.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7236151E5; Thu, 2 Feb 2023 17:39:04 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Define std::basic_stringbuf::view() for old std::string ABI Date: Thu, 2 Feb 2023 17:39:03 +0000 Message-Id: <20230202173903.2638731-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested powerpc64le-linux. Pushed to trunk. This could be backported to gcc-11 and gcc-12 but I have no immediate plans to do that (it's needed on trunk because of the new stuff in and that stuff isn't on the branches). -- >8 -- Unlike the new str()&& members in , there is no real difficulty in supporting the new view() members for the old std::string ABI. Enabling it fixes errors in where std::ostringstream::view() is used by ostream insertion operators for calendar types. We just need to use [[gnu::always_inline]] on the view() members for the old ABI, because the library doesn't contain instantiations of them for the old ABI. Making them always inline avoids needing to add those instantiations and export them. libstdc++-v3/ChangeLog: * include/std/sstream (basic_stringbuf::view): Define for old std::string ABI. (basic_istringstream::view, basic_0stringstream::view) (basic_stringstream::view): Likewise. * testsuite/27_io/basic_istringstream/view/char/1.cc: Remove { dg-require-effective-target cxx11_abi }. * testsuite/27_io/basic_istringstream/view/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_ostringstream/view/char/1.cc: Likewise. * testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_stringbuf/view/char/1.cc: Likewise. * testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_stringstream/view/char/1.cc: Likewise. * testsuite/27_io/basic_stringstream/view/wchar_t/1.cc: Likewise. --- libstdc++-v3/include/std/sstream | 32 +++++++++++++++---- .../27_io/basic_istringstream/view/char/1.cc | 1 - .../basic_istringstream/view/wchar_t/1.cc | 1 - .../27_io/basic_ostringstream/view/char/1.cc | 1 - .../basic_ostringstream/view/wchar_t/1.cc | 1 - .../27_io/basic_stringbuf/view/char/1.cc | 1 - .../27_io/basic_stringbuf/view/wchar_t/1.cc | 1 - .../27_io/basic_stringstream/view/char/1.cc | 1 - .../basic_stringstream/view/wchar_t/1.cc | 1 - 9 files changed, 25 insertions(+), 15 deletions(-) diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream index 4f0c50fcc8a..6b3139714c7 100644 --- a/libstdc++-v3/include/std/sstream +++ b/libstdc++-v3/include/std/sstream @@ -43,10 +43,15 @@ #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_LVAL_REF_QUAL & +# define _GLIBCXX_SSTREAM_ALWAYS_INLINE #else # define _GLIBCXX_LVAL_REF_QUAL +// For symbols that are not exported from libstdc++.so for the COW string ABI. +# define _GLIBCXX_SSTREAM_ALWAYS_INLINE [[__gnu__::__always_inline__]] #endif + + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -251,7 +256,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 return __ret; } -#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cplusplus > 201703L +#if _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> @@ -275,7 +281,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _M_sync(_M_string.data(), 0, 0); return __str; } +#endif // cxx11 ABI + _GLIBCXX_SSTREAM_ALWAYS_INLINE basic_string_view view() const noexcept { @@ -698,7 +706,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 str() const _GLIBCXX_LVAL_REF_QUAL { return _M_stringbuf.str(); } -#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cplusplus > 201703L +#if _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> @@ -709,11 +718,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 __string_type str() && { return std::move(_M_stringbuf).str(); } +#endif // cxx11 ABI + _GLIBCXX_SSTREAM_ALWAYS_INLINE basic_string_view view() const noexcept { return _M_stringbuf.view(); } -#endif +#endif // C++20 /** * @brief Setting a new buffer. @@ -919,7 +930,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 str() const _GLIBCXX_LVAL_REF_QUAL { return _M_stringbuf.str(); } -#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cplusplus > 201703L +#if _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> @@ -930,11 +942,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 __string_type str() && { return std::move(_M_stringbuf).str(); } +#endif // cxx11 ABI + _GLIBCXX_SSTREAM_ALWAYS_INLINE basic_string_view view() const noexcept { return _M_stringbuf.view(); } -#endif +#endif // C++20 /** * @brief Setting a new buffer. @@ -1138,7 +1152,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 str() const _GLIBCXX_LVAL_REF_QUAL { return _M_stringbuf.str(); } -#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI +#if __cplusplus > 201703L +#if _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> @@ -1149,11 +1164,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 __string_type str() && { return std::move(_M_stringbuf).str(); } +#endif // cxx11 ABI + _GLIBCXX_SSTREAM_ALWAYS_INLINE basic_string_view view() const noexcept { return _M_stringbuf.view(); } -#endif +#endif // C++20 /** * @brief Setting a new buffer. @@ -1215,6 +1232,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#undef _GLIBCXX_SSTREAM_ALWAYS_INLINE #undef _GLIBCXX_LVAL_REF_QUAL #include diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc index 5309c448be2..04aae817569 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include diff --git a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc index 774bef10fc5..06b04b3c6b9 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc index 320086153ff..41279083a06 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include diff --git a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc index 1b9b851eb25..2f177d45d70 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc index 998ad5c3e2b..138f4b124e5 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc index 58334084dc1..30b8f0549f4 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc index bd14bc58293..91d329dfa86 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc index d179f4e2201..7af53dcd16f 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc @@ -19,7 +19,6 @@ // { dg-options "-std=gnu++2a" } // { dg-do run { target c++2a } } -// { dg-require-effective-target cxx11_abi } #include #include -- 2.39.1