]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix new <sstream> tests for COW std::string ABI
authorJonathan Wakely <jwakely@redhat.com>
Tue, 10 Jun 2025 09:52:13 +0000 (10:52 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 11 Jun 2025 09:30:05 +0000 (10:30 +0100)
The std::basic_stringbuf::get_allocator() member is only available for
the SSO std::string ABI.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_istringstream/cons/char/string_view.cc:
Only check get_allocator() for new string ABI.
* testsuite/27_io/basic_ostringstream/cons/char/string_view.cc:
Likewise.
* testsuite/27_io/basic_stringbuf/cons/char/string_view.cc:
Likewise.
* testsuite/27_io/basic_stringstream/cons/char/string_view.cc:
Likewise.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
libstdc++-v3/testsuite/27_io/basic_istringstream/cons/char/string_view.cc
libstdc++-v3/testsuite/27_io/basic_ostringstream/cons/char/string_view.cc
libstdc++-v3/testsuite/27_io/basic_stringbuf/cons/char/string_view.cc
libstdc++-v3/testsuite/27_io/basic_stringstream/cons/char/string_view.cc

index 27f65aa94375240e57255888884721045867df9b..f25b538b2fa84a2f5e932a14265ea98397f00d9b 100644 (file)
@@ -151,20 +151,26 @@ void test03()
   alloc_type a{1};
   {
     istringstream_with_alloc<alloc_type> istr(cstr, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( istr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{istr.str()} == cstr );
     VERIFY( istr.get() == cstr.s[0] );
   }
   {
     istringstream_with_alloc<alloc_type> istr(cstr, std::ios::in, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( istr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{istr.str()} == cstr );
     VERIFY( istr.get() == cstr.s[0] );
     VERIFY( istr.rdbuf()->sputc('X') != 'X' );
   }
   {
     istringstream_with_alloc<alloc_type> istr(cstr, std::ios::out, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( istr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{istr.str()} == cstr );
     VERIFY( istr.get() == cstr.s[0] );
     VERIFY( istr.rdbuf()->sputc('X') == 'X' );
index 731e97e4aa2cc28e3f437d29a63675ee32b28f80..6279c19e54c57b00a3756725f4186970edd54604 100644 (file)
@@ -149,21 +149,27 @@ void test03()
   alloc_type a{1};
   {
     ostringstream_with_alloc<alloc_type> ostrstr(cstr, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( ostrstr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{ostrstr.str()} == cstr );
     VERIFY( ostrstr.rdbuf()->sgetc() == ostringstream::traits_type::eof() );
     VERIFY( ostrstr.put('X').good() );
   }
   {
     ostringstream_with_alloc<alloc_type> ostrstr(cstr, std::ios::in, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( ostrstr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{ostrstr.str()} == cstr );
     VERIFY( ostrstr.rdbuf()->sgetc() == cstr.s[0]);
     VERIFY( ostrstr.put('X').good() );
   }
   {
     ostringstream_with_alloc<alloc_type> ostrstr(cstr, std::ios::out, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( ostrstr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{ostrstr.str()} == cstr );
     VERIFY( ostrstr.rdbuf()->sgetc() == ostringstream::traits_type::eof() );
     VERIFY( ostrstr.put('Y').rdstate() == ostrstr.goodbit );
index 7843269c48fd833224c75c749036fccae5933a2f..14278b3faf83b2197f721c3038bbe35a3e27720e 100644 (file)
@@ -161,20 +161,26 @@ void test03()
   alloc_type a{1};
   {
     stringbuf_with_alloc<alloc_type> sbuf(cstr, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( sbuf.get_allocator() == a );
+#endif
     VERIFY( string_view{sbuf.str()} == cstr );
     VERIFY( sbuf.sgetc() == cstr.s[0] );
   }
   {
     stringbuf_with_alloc<alloc_type> sbuf(cstr, std::ios::in, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( sbuf.get_allocator() == a );
+#endif
     VERIFY( string_view{sbuf.str()} == cstr );
     VERIFY( sbuf.sgetc() == cstr.s[0] );
     VERIFY( sbuf.sputc('X') == stringbuf::traits_type::eof() );
   }
   {
     stringbuf_with_alloc<alloc_type> sbuf(cstr, std::ios::out, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( sbuf.get_allocator() == a );
+#endif
     VERIFY( string_view{sbuf.str()} == cstr );
     VERIFY( sbuf.sputc('X') == 'X' );
     VERIFY( sbuf.sgetc() == stringbuf::traits_type::eof() );
index 72085230442f6a3ebaddd513e381787da829dfdf..1c9eceaa55cf233e1fbb5a1699fbb8810ac2290d 100644 (file)
@@ -160,20 +160,26 @@ void test03()
   alloc_type a{1};
   {
     stringstream_with_alloc<alloc_type> strstr(cstr, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( strstr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{strstr.str()} == cstr );
     VERIFY( strstr.get() == cstr.s[0] );
   }
   {
     stringstream_with_alloc<alloc_type> strstr(cstr, std::ios::in, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( strstr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{strstr.str()} == cstr );
     VERIFY( strstr.get() == cstr.s[0] );
     VERIFY( strstr.put('X').rdstate() == strstr.badbit );
   }
   {
     stringstream_with_alloc<alloc_type> strstr(cstr, std::ios::out, a);
+#if _GLIBCXX_USE_CXX11_ABI
     VERIFY( strstr.rdbuf()->get_allocator() == a );
+#endif
     VERIFY( string_view{strstr.str()} == cstr );
     VERIFY( strstr.put('X').good() );
     VERIFY( strstr.get() == stringstream::traits_type::eof());