public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1756] libstdc++: Complete __gnu_debug::string Standard conformity
@ 2022-07-19 18:08 Franथईois Dumont
  0 siblings, 0 replies; only message in thread
From: Franथईois Dumont @ 2022-07-19 18:08 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:c66dc02384782e9456ceffb2f72b8f724c4f6a94

commit r13-1756-gc66dc02384782e9456ceffb2f72b8f724c4f6a94
Author: François Dumont <fdumont@gcc.gnu.org>
Date:   Sat Jul 9 14:15:05 2022 +0200

    libstdc++: Complete __gnu_debug::string Standard conformity
    
    Add testsuite/testsuite_string.h header to help testing __gnu_debug::basic_string like
    std::basic_string depending on _GLIBCXX_DEBUG.
    
    Add using of base type methods in __gnu_debug::basic_string to make use of the method
    overloads when there is no debug version.
    
    Fix _GLIBCXX_DEBUG_PEDANTIC assertions in <debug/string>. This header has to be used directly
    like __gnu_debug::string, it is not included by _GLIBCXX_DEBUG. It means that
    _GLIBCXX_DEBUG_PEDANTIC is not considered to define __glibcxx_check_string and
    __glibcxx_check_string_len which are then empty macros. Now those macros are defined
    directly in <debug/string> and properly consider _GLIBCXX_DEBUG_PEDANTIC.
    
    libstdc++-v3/ChangeLog:
    
            * include/debug/debug.h [_GLIBCXX_DEBUG](__glibcxx_requires_string): Define
            using _GLIBCXX_DEBUG_PEDASSERT.
            [_GLIBCXX_DEBUG](__glibcxx_requires_string_len): Likewise.
            * include/debug/macros.h
            (__glibcxx_check_string, __glibcxx_check_string_len): Move...
            * include/debug/string
            (__glibcxx_check_string, __glibcxx_check_string_len): ...here. And define depending
            on _GLIBCXX_DEBUG_PEDANTIC no matter if _GLIBCXX_DEBUG is defined.
            Add using of std::string find, rfind, find_first_of, find_last_of, find_first_not_of
            and find_last_not_of. Remove debug implementations having no debug assertion.
            * testsuite/util/testsuite_string.h: New file. Provides __gnu_test::string and
            __gnu_test::wtring which definition depends on _GLIBCXX_DEBUG.
            * testsuite/21_strings/basic_string/debug/find1_neg.cc: New test case.
            * testsuite/21_strings/basic_string/debug/find2_neg.cc: New test case.
            * testsuite/21_strings/basic_string/operations/find/char/1.cc:
            Include <testsuite_string.h> and use __gnu_test::string.
            * testsuite/21_strings/basic_string/operations/find/char/2.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/char/3.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/char/4.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/char/5.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/char/6.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc:
            Include <testsuite_string.h> and use __gnu_test::wstring.
            * testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc: Likewise.
            * testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc: Likewise.

Diff:
---
 libstdc++-v3/include/debug/debug.h                 |  5 +-
 libstdc++-v3/include/debug/macros.h                |  4 -
 libstdc++-v3/include/debug/string                  | 95 ++++++++++------------
 .../21_strings/basic_string/debug/find1_neg.cc     | 35 ++++++++
 .../21_strings/basic_string/debug/find2_neg.cc     | 35 ++++++++
 .../basic_string/operations/find/char/1.cc         | 18 ++--
 .../basic_string/operations/find/char/2.cc         | 16 ++--
 .../basic_string/operations/find/char/3.cc         | 14 ++--
 .../basic_string/operations/find/char/4.cc         |  8 +-
 .../basic_string/operations/find/char/5.cc         |  4 +-
 .../basic_string/operations/find/char/6.cc         |  4 +-
 .../basic_string/operations/find/wchar_t/1.cc      | 18 ++--
 .../basic_string/operations/find/wchar_t/2.cc      | 16 ++--
 .../basic_string/operations/find/wchar_t/3.cc      | 14 ++--
 .../basic_string/operations/find/wchar_t/4.cc      |  8 +-
 .../basic_string/operations/find/wchar_t/5.cc      |  4 +-
 .../basic_string/operations/find/wchar_t/6.cc      |  4 +-
 libstdc++-v3/testsuite/util/testsuite_string.h     | 20 +++++
 18 files changed, 199 insertions(+), 123 deletions(-)

diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h
index d3cdfbc044c..28e250f0c50 100644
--- a/libstdc++-v3/include/debug/debug.h
+++ b/libstdc++-v3/include/debug/debug.h
@@ -118,9 +118,10 @@ namespace __gnu_debug
   __glibcxx_check_heap(_First,_Last)
 # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)	\
   __glibcxx_check_heap_pred(_First,_Last,_Pred)
-# define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
+# define __glibcxx_requires_string(_String)	\
+  _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
 # define __glibcxx_requires_string_len(_String,_Len)	\
-  __glibcxx_check_string_len(_String,_Len)
+  _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
 # define __glibcxx_requires_irreflexive(_First,_Last)	\
   __glibcxx_check_irreflexive(_First,_Last)
 # define __glibcxx_requires_irreflexive2(_First,_Last)	\
diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h
index 7b86292d1ef..5fb68324ab2 100644
--- a/libstdc++-v3/include/debug/macros.h
+++ b/libstdc++-v3/include/debug/macros.h
@@ -467,8 +467,4 @@ _GLIBCXX_DEBUG_VERIFY(_This.get_allocator() == _Other.get_allocator(),	\
 		      _M_message(__gnu_debug::__msg_equal_allocs)	\
 		      ._M_sequence(_This, "this"))
 
-#define __glibcxx_check_string(_String) _GLIBCXX_DEBUG_PEDASSERT(_String != 0)
-#define __glibcxx_check_string_len(_String,_Len) \
-  _GLIBCXX_DEBUG_PEDASSERT(_String != 0 || _Len == 0)
-
 #endif
diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string
index 3ec55d42d66..a4482db4af5 100644
--- a/libstdc++-v3/include/debug/string
+++ b/libstdc++-v3/include/debug/string
@@ -49,6 +49,20 @@
 # define _GLIBCXX_INSERT_RETURNS_ITERATOR_ONLY(expr)
 #endif
 
+#ifdef _GLIBCXX_DEBUG_PEDANTIC
+# define __glibcxx_check_string(_String)				\
+  _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(_String != 0,		\
+				    __FILE__, __LINE__,		\
+				    __PRETTY_FUNCTION__);
+# define __glibcxx_check_string_len(_String,_Len)		\
+  _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(_String != 0 || _Len == 0,	\
+				    __FILE__, __LINE__,		\
+				    __PRETTY_FUNCTION__);
+#else
+# define __glibcxx_check_string(_String)
+# define __glibcxx_check_string_len(_String,_Len)
+#endif
+
 namespace __gnu_debug
 {
   /** Checks that __s is non-NULL or __n == 0, and then returns __s. */
@@ -868,34 +882,28 @@ namespace __gnu_debug
 
       using _Base::get_allocator;
 
-      size_type
-      find(const basic_string& __str, size_type __pos = 0) const
-	_GLIBCXX_NOEXCEPT
-      { return _Base::find(__str, __pos); }
+      using _Base::find;
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find(const _CharT* __s, size_type __pos, size_type __n) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find(__s, __pos, __n);
       }
 
+      _GLIBCXX20_CONSTEXPR
       size_type
-      find(const _CharT* __s, size_type __pos = 0) const
+      find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find(__s, __pos);
       }
 
-      size_type
-      find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
-      { return _Base::find(__c, __pos); }
-
-      size_type
-      rfind(const basic_string& __str, size_type __pos = _Base::npos) const
-	_GLIBCXX_NOEXCEPT
-      { return _Base::rfind(__str, __pos); }
+      using _Base::rfind;
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       rfind(const _CharT* __s, size_type __pos, size_type __n) const
       {
@@ -903,6 +911,7 @@ namespace __gnu_debug
 	return _Base::rfind(__s, __pos, __n);
       }
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       rfind(const _CharT* __s, size_type __pos = _Base::npos) const
       {
@@ -910,105 +919,85 @@ namespace __gnu_debug
 	return _Base::rfind(__s, __pos);
       }
 
-      size_type
-      rfind(_CharT __c, size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
-      { return _Base::rfind(__c, __pos); }
-
-      size_type
-      find_first_of(const basic_string& __str, size_type __pos = 0) const
-	_GLIBCXX_NOEXCEPT
-      { return _Base::find_first_of(__str, __pos); }
+      using _Base::find_first_of;
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find_first_of(__s, __pos, __n);
       }
 
+      _GLIBCXX20_CONSTEXPR
       size_type
-      find_first_of(const _CharT* __s, size_type __pos = 0) const
+      find_first_of(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find_first_of(__s, __pos);
       }
 
-      size_type
-      find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
-      { return _Base::find_first_of(__c, __pos); }
-
-      size_type
-      find_last_of(const basic_string& __str,
-		   size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
-      { return _Base::find_last_of(__str, __pos); }
+      using _Base::find_last_of;
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find_last_of(__s, __pos, __n);
       }
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find_last_of(__s, __pos);
       }
 
-      size_type
-      find_last_of(_CharT __c, size_type __pos = _Base::npos) const
-	_GLIBCXX_NOEXCEPT
-      { return _Base::find_last_of(__c, __pos); }
-
-      size_type
-      find_first_not_of(const basic_string& __str, size_type __pos = 0) const
-	_GLIBCXX_NOEXCEPT
-      { return _Base::find_first_not_of(__str, __pos); }
+      using _Base::find_first_not_of;
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string_len(__s, __n);
 	return _Base::find_first_not_of(__s, __pos, __n);
       }
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find_first_not_of(const _CharT* __s, size_type __pos = 0) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find_first_not_of(__s, __pos);
       }
 
-      size_type
-      find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
-      { return _Base::find_first_not_of(__c, __pos); }
-
-      size_type
-      find_last_not_of(const basic_string& __str,
-		       size_type __pos = _Base::npos) const
-	_GLIBCXX_NOEXCEPT
-      { return _Base::find_last_not_of(__str, __pos); }
+      using _Base::find_last_not_of;
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find_last_not_of(__s, __pos, __n);
       }
 
+      _GLIBCXX20_CONSTEXPR
       size_type
       find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
+	_GLIBCXX_NOEXCEPT
       {
 	__glibcxx_check_string(__s);
 	return _Base::find_last_not_of(__s, __pos);
       }
 
-      size_type
-      find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
-	_GLIBCXX_NOEXCEPT
-      { return _Base::find_last_not_of(__c, __pos); }
-
       basic_string
       substr(size_type __pos = 0, size_type __n = _Base::npos) const
       { return basic_string(_Base::substr(__pos, __n)); }
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/debug/find1_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/debug/find1_neg.cc
new file mode 100644
index 00000000000..02babbc59e0
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/debug/find1_neg.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2022 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+
+#define _GLIBCXX_DEBUG_PEDANTIC
+
+#include <debug/string>
+
+void test01()
+{
+  const char* __null_str = 0;
+  __gnu_debug::string str;
+  str.find(__null_str);
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/debug/find2_neg.cc b/libstdc++-v3/testsuite/21_strings/basic_string/debug/find2_neg.cc
new file mode 100644
index 00000000000..89250e2d874
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/debug/find2_neg.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2022 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+
+#define _GLIBCXX_DEBUG_PEDANTIC
+
+#include <debug/string>
+
+void test01()
+{
+  const char* __null_str = 0;
+  __gnu_debug::string str;
+  str.find(__null_str, 0, 0);
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/1.cc
index e76473d88c0..862cfefee69 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/1.cc
@@ -19,22 +19,22 @@
 
 // 21.3.6.1 basic_string find
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void test01(void)
 {
-  typedef std::string::size_type csize_type;
-  typedef std::string::const_reference cref;
-  typedef std::string::reference ref;
-  csize_type npos = std::string::npos;
+  typedef __gnu_test::string::size_type csize_type;
+  typedef __gnu_test::string::const_reference cref;
+  typedef __gnu_test::string::reference ref;
+  csize_type npos = __gnu_test::string::npos;
   csize_type csz01, csz02;
 
   const char str_lit01[] = "mave";
-  const std::string str01("mavericks, santa cruz");
-  std::string str02(str_lit01);
-  std::string str03("s, s");
-  std::string str04;
+  const __gnu_test::string str01("mavericks, santa cruz");
+  __gnu_test::string str02(str_lit01);
+  __gnu_test::string str03("s, s");
+  __gnu_test::string str04;
 
   // size_type find(const string&, size_type pos = 0) const;
   csz01 = str01.find(str01);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/2.cc
index baeab8b933f..756ad85dcaa 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/2.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/2.cc
@@ -19,23 +19,23 @@
 
 // 21.3.6.3 basic_string find_first_of
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void test02(void)
 {
-  typedef std::string::size_type csize_type;
-  csize_type npos = std::string::npos;
+  typedef __gnu_test::string::size_type csize_type;
+  csize_type npos = __gnu_test::string::npos;
   csize_type csz01, csz02;
 
   const char str_lit01[] = "mave";
-  const std::string str01("mavericks, santa cruz");
-  std::string str02(str_lit01);
-  std::string str03("s, s");
-  std::string str04;
+  const __gnu_test::string str01("mavericks, santa cruz");
+  __gnu_test::string str02(str_lit01);
+  __gnu_test::string str03("s, s");
+  __gnu_test::string str04;
 
   // size_type find_first_of(const string&, size_type pos = 0) const;
-  std::string str05("xena rulez");
+  __gnu_test::string str05("xena rulez");
   csz01 = str01.find_first_of(str01);
   VERIFY( csz01 == 0 );
   csz01 = str01.find_first_of(str01, 4);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/3.cc
index 7c21080c5ff..8386ae8264d 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/3.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/3.cc
@@ -19,20 +19,20 @@
 
 // 21.3.6.5 basic_string find_first_not_of
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void test03(void)
 {
-  typedef std::string::size_type csize_type;
-  csize_type npos = std::string::npos;
+  typedef __gnu_test::string::size_type csize_type;
+  csize_type npos = __gnu_test::string::npos;
   csize_type csz01;
 
-  const std::string str01("Bob Rock, per me");
+  const __gnu_test::string str01("Bob Rock, per me");
   const char str_lit01[] = "Bob Rock";
-  std::string str02("ovvero Trivi");
-  std::string str03(str_lit01);
-  std::string str04;
+  __gnu_test::string str02("ovvero Trivi");
+  __gnu_test::string str03(str_lit01);
+  __gnu_test::string str04;
 
   // size_type find_first_not_of(const string&, size_type pos = 0) const;
   csz01 = str01.find_first_not_of(str01);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/4.cc
index cf8c0c9f36d..72965d0731f 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/4.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/4.cc
@@ -19,16 +19,16 @@
 
 // 21.3.6.1 basic_string find
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 // libstdc++/31401
 void test01()
 {
-  typedef std::string::size_type csize_type;
-  csize_type npos = std::string::npos;
+  typedef __gnu_test::string::size_type csize_type;
+  csize_type npos = __gnu_test::string::npos;
 
-  std::string use = "anu";
+  __gnu_test::string use = "anu";
   csize_type pos1 = use.find("a", npos);
 
   VERIFY( pos1 == npos );
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/5.cc
index 7464a3cb97f..a366975308c 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/5.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/5.cc
@@ -24,14 +24,14 @@
 // [string::find.first.not.of]
 // [string::find.last.not.of]
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void
 test03()
 {
   std::string_view str1("bar");
-  std::string str2("foobar");
+  __gnu_test::string str2("foobar");
 
   auto x = str2.find(str1);
   VERIFY (x == 3);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/6.cc
index b901e7d049f..51d7b25c1c6 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/6.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/char/6.cc
@@ -19,13 +19,13 @@
 
 // C++11 21.4.7.2 [string::find] basic_string find
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 // https://gcc.gnu.org/ml/libstdc++/2017-01/msg00021.html
 void test01()
 {
-  typedef std::string string_type;
+  typedef __gnu_test::string string_type;
   string_type::size_type npos = string_type::npos;
 
   string_type use = "aaa";
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc
index f1f554895ee..bb65c0cd15f 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/1.cc
@@ -19,22 +19,22 @@
 
 // 21.3.6.1 basic_string find
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void test01(void)
 {
-  typedef std::wstring::size_type csize_type;
-  typedef std::wstring::const_reference cref;
-  typedef std::wstring::reference ref;
-  csize_type npos = std::wstring::npos;
+  typedef __gnu_test::wstring::size_type csize_type;
+  typedef __gnu_test::wstring::const_reference cref;
+  typedef __gnu_test::wstring::reference ref;
+  csize_type npos = __gnu_test::wstring::npos;
   csize_type csz01, csz02;
 
   const wchar_t str_lit01[] = L"mave";
-  const std::wstring str01(L"mavericks, santa cruz");
-  std::wstring str02(str_lit01);
-  std::wstring str03(L"s, s");
-  std::wstring str04;
+  const __gnu_test::wstring str01(L"mavericks, santa cruz");
+  __gnu_test::wstring str02(str_lit01);
+  __gnu_test::wstring str03(L"s, s");
+  __gnu_test::wstring str04;
 
   // size_type find(const wstring&, size_type pos = 0) const;
   csz01 = str01.find(str01);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc
index e7ab9e8ca20..0bd1533d32e 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/2.cc
@@ -19,23 +19,23 @@
 
 // 21.3.6.3 basic_string find_first_of
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void test02(void)
 {
-  typedef std::wstring::size_type csize_type;
-  csize_type npos = std::wstring::npos;
+  typedef __gnu_test::wstring::size_type csize_type;
+  csize_type npos = __gnu_test::wstring::npos;
   csize_type csz01, csz02;
 
   const wchar_t str_lit01[] = L"mave";
-  const std::wstring str01(L"mavericks, santa cruz");
-  std::wstring str02(str_lit01);
-  std::wstring str03(L"s, s");
-  std::wstring str04;
+  const __gnu_test::wstring str01(L"mavericks, santa cruz");
+  __gnu_test::wstring str02(str_lit01);
+  __gnu_test::wstring str03(L"s, s");
+  __gnu_test::wstring str04;
 
   // size_type find_first_of(const wstring&, size_type pos = 0) const;
-  std::wstring str05(L"xena rulez");
+  __gnu_test::wstring str05(L"xena rulez");
   csz01 = str01.find_first_of(str01);
   VERIFY( csz01 == 0 );
   csz01 = str01.find_first_of(str01, 4);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc
index 9daf26bf4f4..8c595fda3f9 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/3.cc
@@ -19,20 +19,20 @@
 
 // 21.3.6.5 basic_string find_first_not_of
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void test03(void)
 {
-  typedef std::wstring::size_type csize_type;
-  csize_type npos = std::wstring::npos;
+  typedef __gnu_test::wstring::size_type csize_type;
+  csize_type npos = __gnu_test::wstring::npos;
   csize_type csz01;
 
-  const std::wstring str01(L"Bob Rock, per me");
+  const __gnu_test::wstring str01(L"Bob Rock, per me");
   const wchar_t str_lit01[] = L"Bob Rock";
-  std::wstring str02(L"ovvero Trivi");
-  std::wstring str03(str_lit01);
-  std::wstring str04;
+  __gnu_test::wstring str02(L"ovvero Trivi");
+  __gnu_test::wstring str03(str_lit01);
+  __gnu_test::wstring str04;
 
   // size_type find_first_not_of(const string&, size_type pos = 0) const;
   csz01 = str01.find_first_not_of(str01);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc
index f9b9605212a..98c3a18accd 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/4.cc
@@ -19,16 +19,16 @@
 
 // 21.3.6.1 basic_string find
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 // libstdc++/31401
 void test01()
 {
-  typedef std::wstring::size_type csize_type;
-  csize_type npos = std::wstring::npos;
+  typedef __gnu_test::wstring::size_type csize_type;
+  csize_type npos = __gnu_test::wstring::npos;
 
-  std::wstring use = L"anu";
+  __gnu_test::wstring use = L"anu";
   csize_type pos1 = use.find(L"a", npos);
 
   VERIFY( pos1 == npos );
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc
index d04e6138956..76126a79988 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc
@@ -24,14 +24,14 @@
 // [string::find.first.not.of]
 // [string::find.last.not.of]
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 void
 test03()
 {
   std::wstring_view str1(L"bar");
-  std::wstring str2(L"foobar");
+  __gnu_test::wstring str2(L"foobar");
 
   auto x = str2.find(str1);
   VERIFY (x == 3);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc
index 24a8c8178fe..58c4db05163 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/find/wchar_t/6.cc
@@ -19,13 +19,13 @@
 
 // C++11 21.4.7.2 [string::find] basic_string find
 
-#include <string>
+#include <testsuite_string.h>
 #include <testsuite_hooks.h>
 
 // https://gcc.gnu.org/ml/libstdc++/2017-01/msg00021.html
 void test01()
 {
-  typedef std::wstring string_type;
+  typedef __gnu_test::wstring string_type;
   string_type::size_type npos = string_type::npos;
 
   string_type use = L"aaa";
diff --git a/libstdc++-v3/testsuite/util/testsuite_string.h b/libstdc++-v3/testsuite/util/testsuite_string.h
new file mode 100644
index 00000000000..7121ff8ec6d
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/testsuite_string.h
@@ -0,0 +1,20 @@
+#ifndef _GLIBCXX_TESTSUITE_STRING_H
+#define _GLIBCXX_TESTSUITE_STRING_H
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/string>
+namespace __gnu_test
+{
+  using __gnu_debug::string;
+  using __gnu_debug::wstring;
+}
+#else
+# include <string>
+namespace __gnu_test
+{
+  using std::string;
+  using std::wstring;
+}
+#endif
+
+#endif


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-19 18:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 18:08 [gcc r13-1756] libstdc++: Complete __gnu_debug::string Standard conformity Franथईois Dumont

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).