From bf5fe4734cb6840be45d8812bb529f9557bb870a Mon Sep 17 00:00:00 2001
From: Benjamin Kosnik <bkoz@redhat.com>
Date: Wed, 22 Oct 2003 18:58:35 +0000
Subject: [PATCH] locale_facets.h: Correct byname facets for "C" locale.

2003-10-22  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/locale_facets.h: Correct byname facets for "C"
	locale.
	* config/locale/generic/ctype_members.cc: Same.
	* config/locale/generic/messages_members.h: Same.
	* config/locale/gnu/ctype_members.cc: Same.
	* config/locale/gnu/messages_members.h: Same.
	* include/bits/codecvt.h: Same.
	* src/ctype.cc: Same.
	* testsuite/22_locale/codecvt_byname/1.cc: New.
	* testsuite/22_locale/collate/1.cc: Edit.
	* testsuite/22_locale/collate_byname/1.cc: Derivation tests, move to...
	* testsuite/22_locale/collate_byname/named_equivalence.cc: ...here.
	* testsuite/22_locale/ctype/1.cc: Derivation tests.
	* testsuite/22_locale/ctype/11844.cc: Move...
	* testsuite/22_locale/ctype_base/11844.cc: ...here.
	* testsuite/22_locale/ctype_base/1.cc: Move mask bits here.
	* testsuite/22_locale/ctype_byname/1.cc: Name.
	* testsuite/22_locale/messages_byname/1.cc: New.
	* testsuite/22_locale/messages_byname/named_equivalence.cc: New.
	* testsuite/22_locale/moneypunct_byname/1.cc: Derivation test.
	* testsuite/22_locale/moneypunct_byname/named_equivalence.cc: New.
	* testsuite/22_locale/numpunct/1.cc: Edit.
	* testsuite/22_locale/numpunct_byname/2.cc: Move...
	* testsuite/22_locale/numpunct/members/char/3.cc: ...here.
	* testsuite/22_locale/numpunct_byname/1.cc: Derivation tests.
	* testsuite/22_locale/numpunct_byname/named_equivalence.cc: New.

From-SVN: r72814
---
 libstdc++-v3/ChangeLog                        |  29 ++++
 .../config/locale/generic/ctype_members.cc    |   7 +-
 .../config/locale/generic/messages_members.h  |   7 +-
 .../config/locale/gnu/ctype_members.cc        |  15 +-
 .../config/locale/gnu/messages_members.h      |   7 +-
 libstdc++-v3/include/bits/codecvt.h           |   7 +-
 libstdc++-v3/include/bits/locale_facets.h     |  38 +++--
 libstdc++-v3/src/ctype.cc                     |   9 +-
 .../testsuite/22_locale/codecvt_byname/1.cc   |  44 +++++
 libstdc++-v3/testsuite/22_locale/collate/1.cc |   2 +-
 .../testsuite/22_locale/collate_byname/1.cc   | 118 ++------------
 .../collate_byname/named_equivalence.cc       | 135 ++++++++++++++++
 libstdc++-v3/testsuite/22_locale/ctype/1.cc   | 150 ++----------------
 .../testsuite/22_locale/ctype_base/1.cc       |  56 +++++++
 .../22_locale/{ctype => ctype_base}/11844.cc  |   0
 .../testsuite/22_locale/ctype_byname/1.cc     |  42 +++++
 .../testsuite/22_locale/messages_byname/1.cc  |  59 ++-----
 .../messages_byname/named_equivalence.cc      |  78 +++++++++
 .../22_locale/moneypunct_byname/1.cc          |  78 ++-------
 .../moneypunct_byname/named_equivalence.cc    |  98 ++++++++++++
 .../testsuite/22_locale/numpunct/1.cc         |   4 +
 .../2.cc => numpunct/members/char/3.cc}       |   0
 .../testsuite/22_locale/numpunct_byname/1.cc  |  59 ++-----
 .../numpunct_byname/named_equivalence.cc      |  76 +++++++++
 24 files changed, 686 insertions(+), 432 deletions(-)
 create mode 100644 libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc
 create mode 100644 libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc
 create mode 100644 libstdc++-v3/testsuite/22_locale/ctype_base/1.cc
 rename libstdc++-v3/testsuite/22_locale/{ctype => ctype_base}/11844.cc (100%)
 create mode 100644 libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc
 create mode 100644 libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
 create mode 100644 libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc
 rename libstdc++-v3/testsuite/22_locale/{numpunct_byname/2.cc => numpunct/members/char/3.cc} (100%)
 create mode 100644 libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 76d345e19a4b..9100bb19a60e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,32 @@
+2003-10-22  Benjamin Kosnik  <bkoz@redhat.com>
+
+	* include/bits/locale_facets.h: Correct byname facets for "C"
+	locale.
+	* config/locale/generic/ctype_members.cc: Same.
+	* config/locale/generic/messages_members.h: Same.
+	* config/locale/gnu/ctype_members.cc: Same.
+	* config/locale/gnu/messages_members.h: Same.
+	* include/bits/codecvt.h: Same.
+	* src/ctype.cc: Same.
+	* testsuite/22_locale/codecvt_byname/1.cc: New.
+	* testsuite/22_locale/collate/1.cc: Edit.
+	* testsuite/22_locale/collate_byname/1.cc: Derivation tests, move to...
+	* testsuite/22_locale/collate_byname/named_equivalence.cc: ...here.
+	* testsuite/22_locale/ctype/1.cc: Derivation tests.
+	* testsuite/22_locale/ctype/11844.cc: Move...
+	* testsuite/22_locale/ctype_base/11844.cc: ...here.
+	* testsuite/22_locale/ctype_base/1.cc: Move mask bits here.
+	* testsuite/22_locale/ctype_byname/1.cc: Name.
+	* testsuite/22_locale/messages_byname/1.cc: New.
+	* testsuite/22_locale/messages_byname/named_equivalence.cc: New.
+	* testsuite/22_locale/moneypunct_byname/1.cc: Derivation test.
+	* testsuite/22_locale/moneypunct_byname/named_equivalence.cc: New.
+	* testsuite/22_locale/numpunct/1.cc: Edit.
+	* testsuite/22_locale/numpunct_byname/2.cc: Move...
+	* testsuite/22_locale/numpunct/members/char/3.cc: ...here.
+	* testsuite/22_locale/numpunct_byname/1.cc: Derivation tests.
+	* testsuite/22_locale/numpunct_byname/named_equivalence.cc: New.
+
 2003-10-22  Paolo Carlini  <pcarlini@suse.de>
 
 	PR libstdc++/8610
diff --git a/libstdc++-v3/config/locale/generic/ctype_members.cc b/libstdc++-v3/config/locale/generic/ctype_members.cc
index 9b3bddb6bef4..71175f145595 100644
--- a/libstdc++-v3/config/locale/generic/ctype_members.cc
+++ b/libstdc++-v3/config/locale/generic/ctype_members.cc
@@ -43,8 +43,11 @@ namespace std
     ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
     : ctype<char>(0, false, __refs) 
     { 	
-      _S_destroy_c_locale(_M_c_locale_ctype);
-      _S_create_c_locale(_M_c_locale_ctype, __s); 
+      if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	{
+	  _S_destroy_c_locale(_M_c_locale_ctype);
+	  _S_create_c_locale(_M_c_locale_ctype, __s); 
+	}
     }
 
 #ifdef _GLIBCXX_USE_WCHAR_T  
diff --git a/libstdc++-v3/config/locale/generic/messages_members.h b/libstdc++-v3/config/locale/generic/messages_members.h
index 3e9122e880fc..cecc6446c712 100644
--- a/libstdc++-v3/config/locale/generic/messages_members.h
+++ b/libstdc++-v3/config/locale/generic/messages_members.h
@@ -76,6 +76,9 @@
      messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
      : messages<_CharT>(__refs) 
      { 
-       _S_destroy_c_locale(this->_M_c_locale_messages);
-       _S_create_c_locale(this->_M_c_locale_messages, __s); 
+	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	  {
+	    _S_destroy_c_locale(this->_M_c_locale_messages);
+	    _S_create_c_locale(this->_M_c_locale_messages, __s); 
+	  }
      }
diff --git a/libstdc++-v3/config/locale/gnu/ctype_members.cc b/libstdc++-v3/config/locale/gnu/ctype_members.cc
index 79a14f57a482..a5394b53828b 100644
--- a/libstdc++-v3/config/locale/gnu/ctype_members.cc
+++ b/libstdc++-v3/config/locale/gnu/ctype_members.cc
@@ -43,12 +43,15 @@ namespace std
   template<>
     ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
     : ctype<char>(0, false, __refs) 
-    { 	
-      _S_destroy_c_locale(_M_c_locale_ctype);
-      _S_create_c_locale(_M_c_locale_ctype, __s); 
-      _M_toupper = _M_c_locale_ctype->__ctype_toupper;
-      _M_tolower = _M_c_locale_ctype->__ctype_tolower;
-      _M_table = _M_c_locale_ctype->__ctype_b;
+    { 		
+      if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	{
+	  _S_destroy_c_locale(_M_c_locale_ctype);
+	  _S_create_c_locale(_M_c_locale_ctype, __s); 
+	  _M_toupper = _M_c_locale_ctype->__ctype_toupper;
+	  _M_tolower = _M_c_locale_ctype->__ctype_tolower;
+	  _M_table = _M_c_locale_ctype->__ctype_b;
+	}
     }
 
 #ifdef _GLIBCXX_USE_WCHAR_T  
diff --git a/libstdc++-v3/config/locale/gnu/messages_members.h b/libstdc++-v3/config/locale/gnu/messages_members.h
index 9bb8e50c4380..ed95dfb4c43c 100644
--- a/libstdc++-v3/config/locale/gnu/messages_members.h
+++ b/libstdc++-v3/config/locale/gnu/messages_members.h
@@ -106,6 +106,9 @@
        std::strcpy(__tmp, __s);
        this->_M_name_messages = __tmp;
 #endif
-       _S_destroy_c_locale(this->_M_c_locale_messages);
-       _S_create_c_locale(this->_M_c_locale_messages, __s); 
+	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	  {
+	    _S_destroy_c_locale(this->_M_c_locale_messages);
+	    _S_create_c_locale(this->_M_c_locale_messages, __s); 
+	  }
      }
diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h
index 1d123a93c649..80f9cba0b358 100644
--- a/libstdc++-v3/include/bits/codecvt.h
+++ b/libstdc++-v3/include/bits/codecvt.h
@@ -341,8 +341,11 @@
       codecvt_byname(const char* __s, size_t __refs = 0) 
       : codecvt<_InternT, _ExternT, _StateT>(__refs)
       { 
-	_S_destroy_c_locale(this->_M_c_locale_codecvt);
-	_S_create_c_locale(this->_M_c_locale_codecvt, __s); 
+	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	  {
+	    _S_destroy_c_locale(this->_M_c_locale_codecvt);
+	    _S_create_c_locale(this->_M_c_locale_codecvt, __s); 
+	  }
       }
 
     protected:
diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h
index 13383d8d36f4..abb9d143c61e 100644
--- a/libstdc++-v3/include/bits/locale_facets.h
+++ b/libstdc++-v3/include/bits/locale_facets.h
@@ -795,9 +795,6 @@ namespace std
   template<typename _CharT>
     class numpunct_byname : public numpunct<_CharT>
     {
-      // Data Member.
-      __c_locale			_M_c_locale_numpunct;
-
     public:
       typedef _CharT               	char_type;
       typedef basic_string<_CharT> 	string_type;
@@ -806,14 +803,18 @@ namespace std
       numpunct_byname(const char* __s, size_t __refs = 0)
       : numpunct<_CharT>(__refs)
       {
-	this->_S_create_c_locale(_M_c_locale_numpunct, __s);
-	this->_M_initialize_numpunct(_M_c_locale_numpunct);	
+	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	  {
+	    __c_locale __tmp;
+	    this->_S_create_c_locale(__tmp, __s);
+	    this->_M_initialize_numpunct(__tmp);	
+	    this->_S_destroy_c_locale(__tmp); 
+	  }
       }
 
     protected:
       virtual 
-      ~numpunct_byname() 
-      { this->_S_destroy_c_locale(_M_c_locale_numpunct); }
+      ~numpunct_byname() { }	
     };
 
   template<typename _CharT, typename _InIter>
@@ -1151,8 +1152,11 @@ namespace std
       collate_byname(const char* __s, size_t __refs = 0)
       : collate<_CharT>(__refs) 
       { 
-	this->_S_destroy_c_locale(this->_M_c_locale_collate);
-	this->_S_create_c_locale(this->_M_c_locale_collate, __s); 
+	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	  {
+	    this->_S_destroy_c_locale(this->_M_c_locale_collate);
+	    this->_S_create_c_locale(this->_M_c_locale_collate, __s); 
+	  }
       }
 
     protected:
@@ -1589,7 +1593,7 @@ namespace std
       typedef _OutIter   		iter_type;
 
       explicit 
-      time_put_byname(const char* /*__s*/, size_t __refs = 0) 
+      time_put_byname(const char*, size_t __refs = 0) 
       : time_put<_CharT, _OutIter>(__refs) 
       { };
 
@@ -1805,8 +1809,6 @@ namespace std
   template<typename _CharT, bool _Intl>
     class moneypunct_byname : public moneypunct<_CharT, _Intl>
     {
-      __c_locale			_M_c_locale_moneypunct;
-
     public:
       typedef _CharT 			char_type;
       typedef basic_string<_CharT> 	string_type;
@@ -1817,14 +1819,18 @@ namespace std
       moneypunct_byname(const char* __s, size_t __refs = 0)
       : moneypunct<_CharT, _Intl>(__refs)
       {
-	this->_S_create_c_locale(_M_c_locale_moneypunct, __s);
-	this->_M_initialize_moneypunct(_M_c_locale_moneypunct);	
+	if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	  {
+	    __c_locale __tmp;
+	    this->_S_create_c_locale(__tmp, __s);
+	    this->_M_initialize_moneypunct(__tmp);	
+	    this->_S_destroy_c_locale(__tmp); 
+	  }
       }
 
     protected:
       virtual 
-      ~moneypunct_byname() 
-      { this->_S_destroy_c_locale(_M_c_locale_moneypunct); }
+      ~moneypunct_byname() { }
     };
 
   template<typename _CharT, bool _Intl>
diff --git a/libstdc++-v3/src/ctype.cc b/libstdc++-v3/src/ctype.cc
index e97d39dfe1cb..7fb5c2da81fc 100644
--- a/libstdc++-v3/src/ctype.cc
+++ b/libstdc++-v3/src/ctype.cc
@@ -99,9 +99,12 @@ namespace std
   template<>
     ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
     : ctype<wchar_t>(__refs) 
-    { 	
-      _S_destroy_c_locale(_M_c_locale_ctype);
-      _S_create_c_locale(_M_c_locale_ctype, __s); 
+    { 		
+      if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+	{
+	  _S_destroy_c_locale(_M_c_locale_ctype);
+	  _S_create_c_locale(_M_c_locale_ctype, __s); 
+	}
     }
 #endif
 } // namespace std
diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc b/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc
new file mode 100644
index 000000000000..a17c841466b3
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/codecvt_byname/1.cc
@@ -0,0 +1,44 @@
+// { dg-do compile }
+// 2001-08-27  Benjamin Kosnik  <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.1.5  Template class codecvt
+
+#include <locale>
+
+void test01()
+{
+  // Check for required base class.
+  typedef std::codecvt_byname<char, char, mbstate_t> test_type;
+  typedef std::codecvt<char, char, mbstate_t> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  const base_type* base __attribute__((unused)) = &obj;
+  
+  // Check for required typedefs
+  typedef test_type::intern_type intern_type;
+  typedef test_type::extern_type extern_type;
+  typedef test_type::state_type state_type;
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/collate/1.cc b/libstdc++-v3/testsuite/22_locale/collate/1.cc
index 2f6415fcd67d..41f615e3dde0 100644
--- a/libstdc++-v3/testsuite/22_locale/collate/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/collate/1.cc
@@ -26,7 +26,7 @@
 void test01()
 {
   // Check for required base class.
-  typedef std::messages<char> test_type;
+  typedef std::collate<char> test_type;
   typedef std::locale::facet base_type;
   const test_type& obj = std::use_facet<test_type>(std::locale()); 
   const base_type* base __attribute__((unused)) = &obj;
diff --git a/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc b/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc
index be4524f9ca65..6f1f6432ae62 100644
--- a/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/collate_byname/1.cc
@@ -1,6 +1,7 @@
-// 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-08-15  Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2001, 2002 Free Software Foundation
+// Copyright (C) 2001 Free Software Foundation
 //
 // 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
@@ -18,114 +19,21 @@
 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 // USA.
 
-// 22.2.4.2 Template class collate_byname
+// 22.2.4 The collate category
 
 #include <locale>
-#include <testsuite_hooks.h>
 
 void test01()
 {
-  using namespace std;
-  typedef std::collate<char>::string_type string_type;
-
-  bool test __attribute__((unused)) = true;
-  string str;
-  locale loc_c = locale::classic();
-
-  locale loc_de = __gnu_test::try_named_locale("de_DE");
-  str = loc_de.name();
-
-  locale loc_byname(locale::classic(), new collate_byname<char>("de_DE"));
-  str = loc_byname.name();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the collate facets
-  const collate<char>& coll_de = use_facet<collate<char> >(loc_de); 
-
-  // Check German "de_DE" locale.
-  int i1;
-  int i2;
-  long l1;
-  long l2;
-  const char* strlit3 = "Äuglein Augment"; // "C" == "Augment Äuglein"
-  const char* strlit4 = "Base baß Baß Bast"; // "C" == "Base baß Baß Bast"
-
-  int size3 = strlen(strlit3) - 1;
-  i1 = coll_de.compare(strlit3, strlit3 + size3, strlit3, strlit3 + 7);
-  VERIFY ( i1 == 1 );
-  i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size3);
-  VERIFY ( i1 == -1 );
-  i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
-  VERIFY ( i1 == 0 );
-
-  i1 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
-  VERIFY ( i1 == -1 );
-
-  int size4 = strlen(strlit4) - 1;
-  i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
-  VERIFY ( i2 == 1 );
-  i2 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
-  VERIFY ( i2 == -1 );
-  i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
-  VERIFY ( i2 == 0 );
-
-  l1 = coll_de.hash(strlit3, strlit3 + size3);
-  l2 = coll_de.hash(strlit3, strlit3 + size3 - 1);
-  VERIFY ( l1 != l2 );
-  l1 = coll_de.hash(strlit3, strlit3 + size3);
-  l2 = coll_de.hash(strlit4, strlit4 + size4);
-  VERIFY ( l1 != l2 );
-
-  string str3 = coll_de.transform(strlit3, strlit3 + size3);
-  string str4 = coll_de.transform(strlit4, strlit4 + size4);
-  i1 = str3.compare(str4);
-  i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4);
-  VERIFY ( i2 == -1 );
-  VERIFY ( i1 * i2 > 0 );
-
-
-  // Check byname locale
-  int i3;
-  int i4;
-  long l3;
-  long l4;
-  size4 = strlen(strlit3) - 1;
-  i3 = coll_de.compare(strlit3, strlit3 + size4, strlit3, strlit3 + 7);
-  VERIFY ( i3 == 1 );
-  i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size4);
-  VERIFY ( i3 == -1 );
-  i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
-  VERIFY ( i3 == 0 );
-
-  i3 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
-  VERIFY ( i3 == -1 );
-
-  size4 = strlen(strlit4) - 1;
-  i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
-  VERIFY ( i4 == 1 );
-  i4 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
-  VERIFY ( i4 == -1 );
-  i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
-  VERIFY ( i4 == 0 );
-
-  l3 = coll_de.hash(strlit3, strlit3 + size4);
-  l4 = coll_de.hash(strlit3, strlit3 + size4 - 1);
-  VERIFY ( l3 != l4 );
-  l3 = coll_de.hash(strlit3, strlit3 + size4);
-  l4 = coll_de.hash(strlit4, strlit4 + size4);
-  VERIFY ( l3 != l4 );
-
-  string str5 = coll_de.transform(strlit3, strlit3 + size3);
-  string str6 = coll_de.transform(strlit4, strlit4 + size4);
-  i3 = str5.compare(str6);
-  i4 = coll_de.compare(strlit3, strlit3 + size4, strlit4, strlit4 + size4);
-  VERIFY ( i4 == -1 );
-  VERIFY ( i3 * i4 > 0 );
-
-  // Verify byname == de
-  VERIFY ( str5 == str3 );
-  VERIFY ( str6 == str4 );
+  // Check for required base class.
+  typedef std::collate_byname<char> test_type;
+  typedef std::collate<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  const base_type* base __attribute__((unused)) = &obj;
+
+  // Check for required typedefs
+  typedef test_type::char_type char_type;
+  typedef test_type::string_type string_type;
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc
new file mode 100644
index 000000000000..be4524f9ca65
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/collate_byname/named_equivalence.cc
@@ -0,0 +1,135 @@
+// 2001-08-15 Benjamin Kosnik  <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.4.2 Template class collate_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  typedef std::collate<char>::string_type string_type;
+
+  bool test __attribute__((unused)) = true;
+  string str;
+  locale loc_c = locale::classic();
+
+  locale loc_de = __gnu_test::try_named_locale("de_DE");
+  str = loc_de.name();
+
+  locale loc_byname(locale::classic(), new collate_byname<char>("de_DE"));
+  str = loc_byname.name();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the collate facets
+  const collate<char>& coll_de = use_facet<collate<char> >(loc_de); 
+
+  // Check German "de_DE" locale.
+  int i1;
+  int i2;
+  long l1;
+  long l2;
+  const char* strlit3 = "Äuglein Augment"; // "C" == "Augment Äuglein"
+  const char* strlit4 = "Base baß Baß Bast"; // "C" == "Base baß Baß Bast"
+
+  int size3 = strlen(strlit3) - 1;
+  i1 = coll_de.compare(strlit3, strlit3 + size3, strlit3, strlit3 + 7);
+  VERIFY ( i1 == 1 );
+  i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size3);
+  VERIFY ( i1 == -1 );
+  i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
+  VERIFY ( i1 == 0 );
+
+  i1 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
+  VERIFY ( i1 == -1 );
+
+  int size4 = strlen(strlit4) - 1;
+  i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
+  VERIFY ( i2 == 1 );
+  i2 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
+  VERIFY ( i2 == -1 );
+  i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
+  VERIFY ( i2 == 0 );
+
+  l1 = coll_de.hash(strlit3, strlit3 + size3);
+  l2 = coll_de.hash(strlit3, strlit3 + size3 - 1);
+  VERIFY ( l1 != l2 );
+  l1 = coll_de.hash(strlit3, strlit3 + size3);
+  l2 = coll_de.hash(strlit4, strlit4 + size4);
+  VERIFY ( l1 != l2 );
+
+  string str3 = coll_de.transform(strlit3, strlit3 + size3);
+  string str4 = coll_de.transform(strlit4, strlit4 + size4);
+  i1 = str3.compare(str4);
+  i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4);
+  VERIFY ( i2 == -1 );
+  VERIFY ( i1 * i2 > 0 );
+
+
+  // Check byname locale
+  int i3;
+  int i4;
+  long l3;
+  long l4;
+  size4 = strlen(strlit3) - 1;
+  i3 = coll_de.compare(strlit3, strlit3 + size4, strlit3, strlit3 + 7);
+  VERIFY ( i3 == 1 );
+  i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size4);
+  VERIFY ( i3 == -1 );
+  i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
+  VERIFY ( i3 == 0 );
+
+  i3 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
+  VERIFY ( i3 == -1 );
+
+  size4 = strlen(strlit4) - 1;
+  i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
+  VERIFY ( i4 == 1 );
+  i4 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
+  VERIFY ( i4 == -1 );
+  i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
+  VERIFY ( i4 == 0 );
+
+  l3 = coll_de.hash(strlit3, strlit3 + size4);
+  l4 = coll_de.hash(strlit3, strlit3 + size4 - 1);
+  VERIFY ( l3 != l4 );
+  l3 = coll_de.hash(strlit3, strlit3 + size4);
+  l4 = coll_de.hash(strlit4, strlit4 + size4);
+  VERIFY ( l3 != l4 );
+
+  string str5 = coll_de.transform(strlit3, strlit3 + size3);
+  string str6 = coll_de.transform(strlit4, strlit4 + size4);
+  i3 = str5.compare(str6);
+  i4 = coll_de.compare(strlit3, strlit3 + size4, strlit4, strlit4 + size4);
+  VERIFY ( i4 == -1 );
+  VERIFY ( i3 * i4 > 0 );
+
+  // Verify byname == de
+  VERIFY ( str5 == str3 );
+  VERIFY ( str6 == str4 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/ctype/1.cc b/libstdc++-v3/testsuite/22_locale/ctype/1.cc
index adda6fd548d9..ed8122121da4 100644
--- a/libstdc++-v3/testsuite/22_locale/ctype/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/ctype/1.cc
@@ -1,7 +1,7 @@
 // { dg-do compile }
-// 1999-08-24 bkoz
+// 2001-08-15  Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 1999, 2000, 2003 Free Software Foundation
+// Copyright (C) 2003 Free Software Foundation
 //
 // 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
@@ -19,144 +19,26 @@
 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 // USA.
 
-// 22.2.1 The ctype category
-
-// 1: Test that the locale headers are picking up the correct declaration
-// of the internal type `ctype_base::mask'.
-int mask ();
+// 22.2.1.1 - Template class ctype
 
 #include <locale>
 
-// 2: Should be able to instantiate this for other types besides char, wchar_t
-typedef std::ctype<char> cctype;
-
-class gnu_ctype: public std::ctype<unsigned char> 
-{ 
-private:
-  const cctype& _M_cctype;
-
-public:
-  explicit 
-  gnu_ctype(size_t __refs = 0) 
-  : std::ctype<unsigned char>(__refs), 
-    _M_cctype(std::use_facet<cctype>(std::locale::classic())) 
-  { }
-
-  ~gnu_ctype();
-
-protected:
-  virtual bool 
-  do_is(mask __m, char_type __c) const
-  { return _M_cctype.is(__m, __c); }
-
-  virtual const char_type*
-  do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const
-  { 
-    const char* __c = _M_cctype.is(reinterpret_cast<const char*>(__lo), 
-				   reinterpret_cast<const char*>(__hi), __vec);
-    return reinterpret_cast<const char_type*>(__c);
-  }
-  
-  virtual const char_type*
-  do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
-  {
-    const char* __c = _M_cctype.scan_is(__m, 
-					reinterpret_cast<const char*>(__lo), 
-					reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__c);
-  }
-
-  virtual const char_type*
-  do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
-  {
-    const char* __c = _M_cctype.scan_is(__m, 
-					reinterpret_cast<const char*>(__lo), 
-					reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__c);
-  }
-
-  virtual char_type 
-  do_toupper(char_type __c) const
-  { return _M_cctype.toupper(__c); }
-
-  virtual const char_type*
-  do_toupper(char_type* __lo, const char_type* __hi) const
-  {
-    const char* __c = _M_cctype.toupper(reinterpret_cast<char*>(__lo), 
-					reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__c);
-  }
-
-  virtual char_type 
-  do_tolower(char_type __c) const
-  { return _M_cctype.tolower(__c); }
-
-  virtual const char_type*
-  do_tolower(char_type* __lo, const char_type* __hi) const
-  {
-    const char* __c = _M_cctype.toupper(reinterpret_cast<char*>(__lo), 
-					reinterpret_cast<const char*>(__hi));
-    return reinterpret_cast<const char_type*>(__c);
-  }
-
-  virtual char_type 
-  do_widen(char __c) const
-  { return _M_cctype.widen(__c); }
-
-  virtual const char*
-  do_widen(const char* __lo, const char* __hi, char_type* __dest) const
-  {
-    const char* __c = _M_cctype.widen(reinterpret_cast<const char*>(__lo), 
-				      reinterpret_cast<const char*>(__hi),
-				      reinterpret_cast<char*>(__dest));
-    return __c;
-  }
-
-  virtual char 
-  do_narrow(char_type __c, char __dfault) const
-  { return _M_cctype.narrow(__c, __dfault); }
-
-  virtual const char_type*
-  do_narrow(const char_type* __lo, const char_type* __hi, char __dfault, 
-	    char* __dest) const
-  {
-    const char* __c = _M_cctype.narrow(reinterpret_cast<const char*>(__lo), 
-				       reinterpret_cast<const char*>(__hi),
-				       __dfault,
-				       reinterpret_cast<char*>(__dest));
-    return reinterpret_cast<const char_type*>(__c);
-  }
-
-};
-
-gnu_ctype::~gnu_ctype() { }
-
-gnu_ctype facet01;
-
-// 3: Sanity check ctype_base::mask bitmask requirements
-void
-test01()
+void test01()
 {
-  using namespace std;
-
-  ctype_base::mask m01;
-  ctype_base::mask m02;
-  ctype_base::mask res;
-
-  m01 = ctype_base::space;
-  m02 = ctype_base::xdigit;
-
-  res = m01 & m02;
-  res = m01 | m02;
-  res = m01 ^ m02;
-  res = ~m01;
-  m01 &= m02;
-  m01 |= m02;
-  m01 ^= m02;
+  // Check for required base class.
+  typedef std::ctype<char> test_type;
+  typedef std::locale::facet base_type1;
+  typedef std::ctype_base base_type2;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  const base_type1* base1 __attribute__((unused)) = &obj;
+  const base_type2* base2 __attribute__((unused)) = &obj;
+
+  // Check for required typedefs
+  typedef test_type::char_type char_type;
 }
 
-int main() 
-{ 
+int main()
+{
   test01();
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/22_locale/ctype_base/1.cc b/libstdc++-v3/testsuite/22_locale/ctype_base/1.cc
new file mode 100644
index 000000000000..76de50088849
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/ctype_base/1.cc
@@ -0,0 +1,56 @@
+// { dg-do compile }
+// 1999-08-24 bkoz
+
+// Copyright (C) 1999, 2000, 2003 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.1 The ctype category
+
+// 1: Test that the locale headers are picking up the correct declaration
+// of the internal type `ctype_base::mask'.
+int mask ();
+
+#include <locale>
+
+// 2: Sanity check ctype_base::mask bitmask requirements
+void
+test01()
+{
+  using namespace std;
+
+  ctype_base::mask m01;
+  ctype_base::mask m02;
+  ctype_base::mask res;
+
+  m01 = ctype_base::space;
+  m02 = ctype_base::xdigit;
+
+  res = m01 & m02;
+  res = m01 | m02;
+  res = m01 ^ m02;
+  res = ~m01;
+  m01 &= m02;
+  m01 |= m02;
+  m01 ^= m02;
+}
+
+int main() 
+{ 
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/ctype/11844.cc b/libstdc++-v3/testsuite/22_locale/ctype_base/11844.cc
similarity index 100%
rename from libstdc++-v3/testsuite/22_locale/ctype/11844.cc
rename to libstdc++-v3/testsuite/22_locale/ctype_base/11844.cc
diff --git a/libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc b/libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc
new file mode 100644
index 000000000000..61fa30d250ff
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/ctype_byname/1.cc
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// 2001-08-15  Benjamin Kosnik  <bkoz@redhat.com>
+
+// Copyright (C) 2003 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.1.1 - Template class ctype
+
+#include <locale>
+
+void test01()
+{
+  // Check for required base class.
+  typedef std::ctype_byname<char> test_type;
+  typedef std::ctype<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  const base_type* base __attribute__((unused)) = &obj;
+
+  // Check for required typedefs
+  typedef test_type::char_type char_type;
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc
index 3072383a9883..5b9b5d7324cf 100644
--- a/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/messages_byname/1.cc
@@ -1,4 +1,5 @@
-// 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-07-17  Benjamin Kosnik  <bkoz@redhat.com>
 
 // Copyright (C) 2001, 2003 Free Software Foundation
 //
@@ -18,57 +19,21 @@
 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 // USA.
 
-// 22.2.7.2 Template class messages_byname
+// 22.2.7 The message retrieval category
 
 #include <locale>
-#include <testsuite_hooks.h>
 
 void test01()
 {
-  using namespace std;
-  typedef std::messages<char>::catalog catalog;
-  typedef std::messages<char>::string_type string_type;
-
-  bool test __attribute__((unused)) = true;
-  string str;
-  // This is defined through CXXFLAGS in scripts/testsuite_flags[.in].
-  const char* dir = LOCALEDIR;
-  locale loc_c = locale::classic();
-
-  locale loc_de = __gnu_test::try_named_locale("de_DE");
-  str = loc_de.name();
-
-  locale loc_byname(locale::classic(), new messages_byname<char>("de_DE"));
-  str = loc_byname.name();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the messages facets
-  const messages<char>& mssg_byname = use_facet<messages<char> >(loc_byname); 
-  const messages<char>& mssg_de = use_facet<messages<char> >(loc_de); 
-
-  // catalog open(const string&, const locale&) const;
-  // string_type get(catalog, int, int, const string_type& ) const; 
-  // void close(catalog) const;
-
-  // Check German (de_DE) locale.
-  catalog cat_de = mssg_de.open("libstdc++", loc_c, dir);
-  string s01 = mssg_de.get(cat_de, 0, 0, "please");
-  string s02 = mssg_de.get(cat_de, 0, 0, "thank you");
-  VERIFY ( s01 == "bitte" );
-  VERIFY ( s02 == "danke" );
-  mssg_de.close(cat_de);
-
-  // Check byname locale.
-  catalog cat_byname = mssg_byname.open("libstdc++", loc_c, dir);
-  string s03 = mssg_byname.get(cat_de, 0, 0, "please");
-  string s04 = mssg_byname.get(cat_de, 0, 0, "thank you");
-  VERIFY ( s03 == "bitte" );
-  VERIFY ( s04 == "danke" );
-  mssg_byname.close(cat_byname);
-
-  VERIFY ( s01 == s03 );
-  VERIFY ( s02 == s04 );
+  // Check for required base class.
+  typedef std::messages_byname<char> test_type;
+  typedef std::messages<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale::classic()); 
+  const base_type* base __attribute__((unused)) = &obj;
+
+  // Check for required typedefs
+  typedef test_type::char_type char_type;
+  typedef test_type::string_type string_type;
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
new file mode 100644
index 000000000000..3072383a9883
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc
@@ -0,0 +1,78 @@
+// 2001-07-17 Benjamin Kosnik  <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.7.2 Template class messages_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  typedef std::messages<char>::catalog catalog;
+  typedef std::messages<char>::string_type string_type;
+
+  bool test __attribute__((unused)) = true;
+  string str;
+  // This is defined through CXXFLAGS in scripts/testsuite_flags[.in].
+  const char* dir = LOCALEDIR;
+  locale loc_c = locale::classic();
+
+  locale loc_de = __gnu_test::try_named_locale("de_DE");
+  str = loc_de.name();
+
+  locale loc_byname(locale::classic(), new messages_byname<char>("de_DE"));
+  str = loc_byname.name();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the messages facets
+  const messages<char>& mssg_byname = use_facet<messages<char> >(loc_byname); 
+  const messages<char>& mssg_de = use_facet<messages<char> >(loc_de); 
+
+  // catalog open(const string&, const locale&) const;
+  // string_type get(catalog, int, int, const string_type& ) const; 
+  // void close(catalog) const;
+
+  // Check German (de_DE) locale.
+  catalog cat_de = mssg_de.open("libstdc++", loc_c, dir);
+  string s01 = mssg_de.get(cat_de, 0, 0, "please");
+  string s02 = mssg_de.get(cat_de, 0, 0, "thank you");
+  VERIFY ( s01 == "bitte" );
+  VERIFY ( s02 == "danke" );
+  mssg_de.close(cat_de);
+
+  // Check byname locale.
+  catalog cat_byname = mssg_byname.open("libstdc++", loc_c, dir);
+  string s03 = mssg_byname.get(cat_de, 0, 0, "please");
+  string s04 = mssg_byname.get(cat_de, 0, 0, "thank you");
+  VERIFY ( s03 == "bitte" );
+  VERIFY ( s04 == "danke" );
+  mssg_byname.close(cat_byname);
+
+  VERIFY ( s01 == s03 );
+  VERIFY ( s02 == s04 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc
index 2cdef4b1abc1..e85bf230a8d6 100644
--- a/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/1.cc
@@ -1,4 +1,5 @@
-// 2001-08-24 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-08-23  Benjamin Kosnik  <bkoz@redhat.com>
 
 // Copyright (C) 2001, 2003 Free Software Foundation
 //
@@ -18,77 +19,22 @@
 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 // USA.
 
-// 22.2.6.4 Template class moneypunct_byname
+// 22.2.6.3  Template class moneypunct
 
 #include <locale>
 #include <testsuite_hooks.h>
 
 void test01()
 {
-  using namespace std;
-  typedef money_base::part part;
-  typedef money_base::pattern pattern;
-
-  bool test __attribute__((unused)) = true;
-  string str;
-
-  locale loc_de = __gnu_test::try_named_locale("de_DE");
-  str = loc_de.name();
-
-  locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE"));
-  str = loc_byname.name();
-
-  locale loc_c = locale::classic();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the moneypunct facets
-  const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c); 
-  const moneypunct<char>& monp_byname = 
-                                    use_facet<moneypunct<char> >(loc_byname); 
-  const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de); 
-
-  // sanity check that the data match
-  char dp1 = monp_de.decimal_point();
-  char th1 = monp_de.thousands_sep();
-  string g1 = monp_de.grouping();
-  string cs1 = monp_de.curr_symbol();
-  string ps1 = monp_de.positive_sign();
-  string ns1 = monp_de.negative_sign();
-  int fd1 = monp_de.frac_digits();
-  pattern pos1 = monp_de.pos_format();
-  pattern neg1 = monp_de.neg_format();
-
-  char dp2 = monp_byname.decimal_point();
-  char th2 = monp_byname.thousands_sep();
-  string g2 = monp_byname.grouping();
-  string cs2 = monp_byname.curr_symbol();
-  string ps2 = monp_byname.positive_sign();
-  string ns2 = monp_byname.negative_sign();
-  int fd2 = monp_byname.frac_digits();
-  pattern pos2 = monp_byname.pos_format();
-  pattern neg2 = monp_byname.neg_format();
-
-  VERIFY( dp1 == dp2 );
-  VERIFY( th1 == th2 );
-  VERIFY( g1 == g2 );
-  VERIFY( cs1 == cs2 );
-  VERIFY( ps1 == ps2 );
-  VERIFY( ns1 == ns2 );
-  VERIFY( fd1 == fd2 );
-  VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
-  VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
-  VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
-  VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
-
-  VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
-  VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
-  VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2]));
-  VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(neg2.field[3]));
-
-  // ...and don't match "C"
-  char dp3 = monp_c.decimal_point();
-  VERIFY( dp1 != dp3 );
+  // Check for required base class.
+  typedef std::moneypunct_byname<char, true> test_type;
+  typedef std::moneypunct<char, true> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale()); 
+  const base_type* base __attribute__((unused)) = &obj;
+  
+  // Check for required typedefs
+  typedef test_type::char_type char_type;
+  typedef test_type::string_type string_type;
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc
new file mode 100644
index 000000000000..2cdef4b1abc1
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/moneypunct_byname/named_equivalence.cc
@@ -0,0 +1,98 @@
+// 2001-08-24 Benjamin Kosnik  <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.6.4 Template class moneypunct_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  typedef money_base::part part;
+  typedef money_base::pattern pattern;
+
+  bool test __attribute__((unused)) = true;
+  string str;
+
+  locale loc_de = __gnu_test::try_named_locale("de_DE");
+  str = loc_de.name();
+
+  locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE"));
+  str = loc_byname.name();
+
+  locale loc_c = locale::classic();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the moneypunct facets
+  const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c); 
+  const moneypunct<char>& monp_byname = 
+                                    use_facet<moneypunct<char> >(loc_byname); 
+  const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de); 
+
+  // sanity check that the data match
+  char dp1 = monp_de.decimal_point();
+  char th1 = monp_de.thousands_sep();
+  string g1 = monp_de.grouping();
+  string cs1 = monp_de.curr_symbol();
+  string ps1 = monp_de.positive_sign();
+  string ns1 = monp_de.negative_sign();
+  int fd1 = monp_de.frac_digits();
+  pattern pos1 = monp_de.pos_format();
+  pattern neg1 = monp_de.neg_format();
+
+  char dp2 = monp_byname.decimal_point();
+  char th2 = monp_byname.thousands_sep();
+  string g2 = monp_byname.grouping();
+  string cs2 = monp_byname.curr_symbol();
+  string ps2 = monp_byname.positive_sign();
+  string ns2 = monp_byname.negative_sign();
+  int fd2 = monp_byname.frac_digits();
+  pattern pos2 = monp_byname.pos_format();
+  pattern neg2 = monp_byname.neg_format();
+
+  VERIFY( dp1 == dp2 );
+  VERIFY( th1 == th2 );
+  VERIFY( g1 == g2 );
+  VERIFY( cs1 == cs2 );
+  VERIFY( ps1 == ps2 );
+  VERIFY( ns1 == ns2 );
+  VERIFY( fd1 == fd2 );
+  VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
+  VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
+  VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
+  VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
+
+  VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
+  VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
+  VERIFY(static_cast<part>(neg1.field[2]) == static_cast<part>(neg2.field[2]));
+  VERIFY(static_cast<part>(neg1.field[3]) == static_cast<part>(neg2.field[3]));
+
+  // ...and don't match "C"
+  char dp3 = monp_c.decimal_point();
+  VERIFY( dp1 != dp3 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct/1.cc b/libstdc++-v3/testsuite/22_locale/numpunct/1.cc
index 955eaef45f1c..9c2b6925bcc6 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct/1.cc
@@ -30,6 +30,10 @@ void test01()
   typedef std::locale::facet base_type;
   const test_type& obj = std::use_facet<test_type>(std::locale()); 
   const base_type* base __attribute__((unused)) = &obj;
+
+  // Check for required typedefs
+  typedef test_type::char_type char_type;
+  typedef test_type::string_type string_type;
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname/2.cc b/libstdc++-v3/testsuite/22_locale/numpunct/members/char/3.cc
similarity index 100%
rename from libstdc++-v3/testsuite/22_locale/numpunct_byname/2.cc
rename to libstdc++-v3/testsuite/22_locale/numpunct/members/char/3.cc
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc b/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc
index 171149ec7675..8167788cdd59 100644
--- a/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc
+++ b/libstdc++-v3/testsuite/22_locale/numpunct_byname/1.cc
@@ -1,6 +1,7 @@
-// 2001-01-24 Benjamin Kosnik  <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-01-23  Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2001, 2003 Free Software Foundation
+// Copyright (C) 2001, 2003  Free Software Foundation
 //
 // 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
@@ -18,55 +19,21 @@
 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 // USA.
 
-// 22.2.3.2 Template class numpunct_byname
+// 22.2.3  The numeric punctuation facet
 
 #include <locale>
-#include <testsuite_hooks.h>
 
 void test01()
 {
-  using namespace std;
-  
-  bool test __attribute__((unused)) = true;
-  string str;
-
-  locale loc_de = __gnu_test::try_named_locale("de_DE");
-  str = loc_de.name();
-
-  locale loc_byname(locale::classic(), new numpunct_byname<char>("de_DE"));
-  str = loc_byname.name();
-
-  locale loc_c = locale::classic();
-
-  VERIFY( loc_de != loc_byname );
-
-  // cache the numpunct facets
-  const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c); 
-  const numpunct<char>& nump_byname = use_facet<numpunct<char> >(loc_byname); 
-  const numpunct<char>& nump_de = use_facet<numpunct<char> >(loc_de); 
-
-  // sanity check that the data match
-  char dp1 = nump_byname.decimal_point();
-  char th1 = nump_byname.thousands_sep();
-  string g1 = nump_byname.grouping();
-  string t1 = nump_byname.truename();
-  string f1 = nump_byname.falsename();
-
-  char dp2 = nump_de.decimal_point();
-  char th2 = nump_de.thousands_sep();
-  string g2 = nump_de.grouping();
-  string t2 = nump_de.truename();
-  string f2 = nump_de.falsename();
-
-  VERIFY( dp1 == dp2 );
-  VERIFY( th1 == th2 );
-  VERIFY( g1 == g2 );
-  VERIFY( t1 == t2 );
-  VERIFY( f1 == f2 );
-
-  // ...and don't match "C"
-  char dp3 = nump_c.decimal_point();
-  VERIFY( dp1 != dp3 );
+  // Check for required base class.
+  typedef std::numpunct_byname<char> test_type;
+  typedef std::numpunct<char> base_type;
+  const test_type& obj = std::use_facet<test_type>(std::locale()); 
+  const base_type* base __attribute__((unused)) = &obj;
+
+  // Check for required typedefs
+  typedef test_type::char_type char_type;
+  typedef test_type::string_type string_type;
 }
 
 int main()
diff --git a/libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc b/libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc
new file mode 100644
index 000000000000..171149ec7675
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/numpunct_byname/named_equivalence.cc
@@ -0,0 +1,76 @@
+// 2001-01-24 Benjamin Kosnik  <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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 2, 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 COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.3.2 Template class numpunct_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  using namespace std;
+  
+  bool test __attribute__((unused)) = true;
+  string str;
+
+  locale loc_de = __gnu_test::try_named_locale("de_DE");
+  str = loc_de.name();
+
+  locale loc_byname(locale::classic(), new numpunct_byname<char>("de_DE"));
+  str = loc_byname.name();
+
+  locale loc_c = locale::classic();
+
+  VERIFY( loc_de != loc_byname );
+
+  // cache the numpunct facets
+  const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c); 
+  const numpunct<char>& nump_byname = use_facet<numpunct<char> >(loc_byname); 
+  const numpunct<char>& nump_de = use_facet<numpunct<char> >(loc_de); 
+
+  // sanity check that the data match
+  char dp1 = nump_byname.decimal_point();
+  char th1 = nump_byname.thousands_sep();
+  string g1 = nump_byname.grouping();
+  string t1 = nump_byname.truename();
+  string f1 = nump_byname.falsename();
+
+  char dp2 = nump_de.decimal_point();
+  char th2 = nump_de.thousands_sep();
+  string g2 = nump_de.grouping();
+  string t2 = nump_de.truename();
+  string f2 = nump_de.falsename();
+
+  VERIFY( dp1 == dp2 );
+  VERIFY( th1 == th2 );
+  VERIFY( g1 == g2 );
+  VERIFY( t1 == t2 );
+  VERIFY( f1 == f2 );
+
+  // ...and don't match "C"
+  char dp3 = nump_c.decimal_point();
+  VERIFY( dp1 != dp3 );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
-- 
GitLab