From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id B8B08385800B; Mon, 18 Mar 2024 14:06:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8B08385800B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710770791; bh=Se32Q5LdxTHT0mOl6cRObBU3FPTS8hPdrxqoiGQE2jU=; h=From:To:Subject:Date:From; b=nH2habvVQpR90PL5tyd9Egsq88nO1hUakpkEqZVhcuu1HzTK1iYJ7kwO2jTeM6+gy GqZUwLDhF8BrtOByzFmbERYsF5npQRQYrXvTVqhXnNGV7imQl09Jek12aScFLP5Ebt K1ORl+eHy8m+/ckz41+6ZzBjjlSX4no4y2Cj/L5Q= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-10257] libstdc++: Define std::basic_stringbuf::view() for old std::string ABI X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 0135f93383b72b24ac62a82593b3ce30d0c3b69f X-Git-Newrev: e35b26c2442b61e7f45deb5ef3062d0ab6ec584b Message-Id: <20240318140631.B8B08385800B@sourceware.org> Date: Mon, 18 Mar 2024 14:06:31 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e35b26c2442b61e7f45deb5ef3062d0ab6ec584b commit r12-10257-ge35b26c2442b61e7f45deb5ef3062d0ab6ec584b Author: Jonathan Wakely Date: Tue Jan 31 22:32:15 2023 +0000 libstdc++: Define std::basic_stringbuf::view() for old std::string ABI 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_stringstream::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. (cherry picked from commit 331b4f168a06cd85fe40fd03b48b128cc8af399c) Diff: --- libstdc++-v3/include/std/sstream | 32 +++++++++++++++++----- .../27_io/basic_istringstream/view/char/1.cc | 1 - .../27_io/basic_istringstream/view/wchar_t/1.cc | 1 - .../27_io/basic_ostringstream/view/char/1.cc | 1 - .../27_io/basic_ostringstream/view/wchar_t/1.cc | 1 - .../testsuite/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 - .../27_io/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 bc7d636e702..3a86888a76c 100644 --- a/libstdc++-v3/include/std/sstream +++ b/libstdc++-v3/include/std/sstream @@ -41,10 +41,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 @@ -249,7 +254,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> @@ -273,7 +279,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 { @@ -696,7 +704,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> @@ -707,11 +716,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. @@ -917,7 +928,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> @@ -928,11 +940,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. @@ -1136,7 +1150,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> @@ -1147,11 +1162,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. @@ -1213,6 +1230,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 a237b91afba..bf559051f68 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 b7f65b8a26b..3385e5d68b7 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 b0e1ca579b1..46206be802e 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 508176c5583..e239a71d580 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 8e8440233ae..908f349543b 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 5c56c4a622a..26b2fc0a1a4 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 b6daaf6181b..3f3af112d45 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 b3a7f6e024f..d4fa96d43dc 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