On 07/10/20 09:55 -0700, Thomas Rodgers wrote:
From: Thomas Rodgers <trodg...@redhat.com>

New ctors and ::view() accessor for -
 * basic_stingbuf
 * basic_istringstream
 * basic_ostringstream
 * basic_stringstreamm

New ::get_allocator() accessor for basic_stringbuf.

libstdc++-v3/ChangeLog:
        * acinclude.m4 (glibcxx_SUBDIRS): Add src/c++20.
       * config/abi/pre/gnu.ver: Update GLIBCXX_3.4.29 for the addition of -
        basic_stringbuf::basic_stringbuf(allocator const&),
        basic_stringbuf::basic_stringbuf(openmode, allocator const&),
        basic_stringbuf::basic_stringbuf(basic_string&&, openmode),
        basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator const&),
        basic_stringbuf::get_allocator(),
        basic_stringbuf::view(),
        basic_istringstream::basic_istringstream(basic_string&&, openmode),
        basic_istringstream::basic_istringstream(openmode, allocator const&),
        basic_istringstream::view(),
        basic_ostringstream::basic_ostringstream(basic_string&&, openmode),
        basic_ostringstream::basic_ostringstream(openmode, allocator const&),
        basic_ostringstream::view(),
        basic_stringstream::basic_stringstream(basic_string&&, openmode),
        basic_stringstream::basic_stringstream(openmode, allocator const&),
        basic_stringstream::view().
        * configure: Regenerate.
        * include/std/sstream:
        (basic_stringbuf::basic_stringbuf(allocator const&)): New constructor.
        (basic_stringbuf::basic_stringbuf(openmode, allocator const&)): 
Likewise.
        (basic_stringbuf::basic_stringbuf(basic_string&&, openmode)): Likewise.
        (basic_stringbuf::basic_stringbuf(basic_stringbuf&&, allocator 
const&)): Likewise.
        (basic_stringbuf::get_allocator()): New method.
        (basic_stringbuf::view()): Likewise.
        (basic_istringstream::basic_istringstream(basic_string&&, openmode)):
        New constructor.
        (basic_istringstream::basic_istringstream(openmode, allocator const&)):
        Likewise
        (basic_istringstream::view()): New method.
        (basic_ostringstream::basic_ostringstream(basic_string&&, openmode)):
        New constructor.
        (basic_ostringstream::basic_ostringstream(openmode, allocator const&)):
        Likewise
        (basic_ostringstream::view()): New method.
        (basic_stringstream::basic_stringstream(basic_string&&, openmode)):
        New constructor.
        (basic_stringstream::basic_stringstream(openmode, allocator const&)):
        Likewise
        (basic_stringstream::view()): New method.
        * src/Makefile.in: Add c++20 directory.
        * src/Makefile.am: Regenerate.
        * src/c++20/Makefile.am: Add makefile for new sub-directory.
        * src/c++20/Makefile.in: Generate.
        * src/c++20/sstream-inst.cc: New file defining explicit
        instantiations for basic_stringbuf, basic_istringstream,
        basic_ostringstream, and basic_stringstream member functions
        added in C++20.
        * testsuite/27_io/basic_stringbuf/cons/char/2.cc: New test.
        * testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc: Likewise.
        * testsuite/27_io/basic_stringbuf/view/char/2.cc: Likewise.
        * testsuite/27_io/basic_stringbuf/view/wchar_t/2.cc: Likewise.
        * testsuite/27_io/basic_istringstream/cons/char/2.cc: Likewise.
        * testsuite/27_io/basic_istringstream/cons/wchar_t/2.cc: Likewise.
        * testsuite/27_io/basic_istringstream/view/char/2.cc: Likewise.
        * testsuite/27_io/basic_istringstream/view/wchar_t/2.cc: Likewise.
        * testsuite/27_io/basic_ostringstream/cons/char/2.cc: Likewise.
        * testsuite/27_io/basic_ostringstream/cons/wchar_t/2.cc: Likewise.
        * testsuite/27_io/basic_ostringstream/view/char/2.cc: Likewise.
        * testsuite/27_io/basic_ostringstream/view/wchar_t/2.cc: Likewise.
        * testsuite/27_io/basic_stringstream/cons/char/2.cc: Likewise.
        * testsuite/27_io/basic_stringstream/cons/wchar_t/2.cc: Likewise.
        * testsuite/27_io/basic_stringstream/view/char/2.cc: Likewise.
        * testsuite/27_io/basic_stringstream/view/wchar_t/2.cc: Likewise.
---
.topdeps                                      |   1 +
.topmsg                                       |   2 +
libstdc++-v3/acinclude.m4                     |   2 +-
libstdc++-v3/config/abi/pre/gnu.ver           |  60 ++
libstdc++-v3/configure                        |  16 +-
libstdc++-v3/include/std/sstream              | 198 +++++
libstdc++-v3/src/Makefile.am                  |  12 +-
libstdc++-v3/src/Makefile.in                  |  14 +-
libstdc++-v3/src/c++20/Makefile.am            | 105 +++
libstdc++-v3/src/c++20/Makefile.in            | 735 ++++++++++++++++++
libstdc++-v3/src/c++20/sstream-inst.cc        | 110 +++
.../27_io/basic_istringstream/cons/char/1.cc  |  84 ++
.../basic_istringstream/cons/wchar_t/1.cc     |  84 ++
.../27_io/basic_istringstream/view/char/1.cc  |  34 +
.../basic_istringstream/view/wchar_t/1.cc     |  35 +
.../27_io/basic_ostringstream/cons/char/1.cc  |  84 ++
.../basic_ostringstream/cons/wchar_t/1.cc     |  84 ++
.../27_io/basic_ostringstream/view/char/1.cc  |  34 +
.../basic_ostringstream/view/wchar_t/1.cc     |  35 +
.../27_io/basic_stringbuf/cons/char/2.cc      | 120 +++
.../27_io/basic_stringbuf/cons/wchar_t/2.cc   | 105 +++
.../27_io/basic_stringbuf/view/char/1.cc      |  34 +
.../27_io/basic_stringbuf/view/wchar_t/1.cc   |  35 +
.../27_io/basic_stringstream/cons/char/1.cc   |  84 ++
.../basic_stringstream/cons/wchar_t/1.cc      |  84 ++
.../27_io/basic_stringstream/view/char/1.cc   |  34 +
.../basic_stringstream/view/wchar_t/1.cc      |  35 +
27 files changed, 2248 insertions(+), 12 deletions(-)
create mode 100644 .topdeps
create mode 100644 .topmsg
create mode 100644 libstdc++-v3/src/c++20/Makefile.am
create mode 100644 libstdc++-v3/src/c++20/Makefile.in
create mode 100644 libstdc++-v3/src/c++20/sstream-inst.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_istringstream/cons/wchar_t/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_istringstream/view/char/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_istringstream/view/wchar_t/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/wchar_t/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_ostringstream/view/char/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_ostringstream/view/wchar_t/1.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/2.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/wchar_t/2.cc
create mode 100644 libstdc++-v3/testsuite/27_io/basic_stringbuf/view/char/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_stringbuf/view/wchar_t/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_stringstream/cons/wchar_t/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_stringstream/view/char/1.cc
create mode 100644 
libstdc++-v3/testsuite/27_io/basic_stringstream/view/wchar_t/1.cc

diff --git a/.topdeps b/.topdeps
new file mode 100644
index 00000000000..1f7391f92b6
--- /dev/null
+++ b/.topdeps
@@ -0,0 +1 @@
+master
diff --git a/.topmsg b/.topmsg
new file mode 100644
index 00000000000..0c035ed2f0c
--- /dev/null
+++ b/.topmsg
@@ -0,0 +1,2 @@
+From: Thomas Rodgers <trodg...@redhat.com>
+Subject: [PATCH] t/trodgers/c2a_sstream
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 133125ec4fa..b9452dd74cd 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -49,7 +49,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
  # Keep these sync'd with the list in Makefile.am.  The first provides an
  # expandable list at autoconf time; the second provides an expandable list
  # (i.e., shell variable) at configure time.
-  m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 
src/c++17 src/filesystem doc po testsuite python])
+  m4_define([glibcxx_SUBDIRS],[include libsupc++ src src/c++98 src/c++11 
src/c++17 src/c++20 src/filesystem doc po testsuite python])
  SUBDIRS='glibcxx_SUBDIRS'

  # These need to be absolute paths, yet at the same time need to
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver 
b/libstdc++-v3/config/abi/pre/gnu.ver
index 87a48a21f53..3239bb1a53d 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2322,6 +2322,66 @@ GLIBCXX_3.4.29 {
    # std::__atomic_futex_unsigned_base::_M_futex_wait_until_steady
    _ZNSt28__atomic_futex_unsigned_base26_M_futex_wait_until_steady*;

+    # basic_stringbuf::basic_stringbuf(allocator const&)
+    _ZNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEC1ERKS3_;
+    _ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEEC1ERKS3_;

Please combine these symbols by using [cw] wherever the char_type
appears e.g.

    # basic_stringbuf::basic_stringbuf(allocator const&)
    _ZNSt7__cxx1115basic_stringbufI[cw]St11char_traitsI[cw]ESaI[cw]EEC1ERKS3_;

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 7abf1b1ccc1..eecf63f4a59 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure

This is a generated file so can be filtered out of the patch.


diff --git a/libstdc++-v3/src/c++20/sstream-inst.cc 
b/libstdc++-v3/src/c++20/sstream-inst.cc
new file mode 100644
index 00000000000..c7fa065bf18
--- /dev/null
+++ b/libstdc++-v3/src/c++20/sstream-inst.cc
@@ -0,0 +1,110 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882:
+//
+
+#ifndef _GLIBCXX_USE_CXX11_ABI
+// Instantiations in this file use the new SSO std::string ABI unless included
+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
+# define _GLIBCXX_USE_CXX11_ABI 1
+#endif

Nothing includes this with _GLIBCXX_USE_CXX11_ABI=0 defined. That
means all the tests will fail if run with that defined, e.g.

make check RUNTESTFLAGS="conformance.exp=27_io/*string* 
--target_board=unix/-D_GLIBCXX_USE_CXX11_ABI=0"

Either you need to add a src/c++20/cow-sstream-inst.cc file that does:

#define _GLIBCXX_USE_CXX11_ABI 0
#include "sstream-inst.cc"

and then export all the resulting symbols, or the new features should
only be defined for the new ABI, i.e. instead of

#if __cplusplus > 201703L

they should be guarded by

#if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI


I'm not sure how feasible it is to make the new features work with the
old ABI, as the old std::string doesn't propagate allocators properly.
It might just work with no extra effort needed though.

If it doesn't work, and the features are disabled for the old ABI,
then all the new tests need:

// { dg-require-effective-target cxx11-abi }

so that they are skipped as UNSUPPORTED when run with
_GLIBCXX_USE_CXX11_ABI=0 defined.

Reply via email to