From f1197ae1607b1834578d4470fb7ed85870f7dd77 Mon Sep 17 00:00:00 2001
From: Matt Austern <austern@apple.com>
Date: Mon, 2 Aug 2004 04:40:19 +0000
Subject: [PATCH] re PR libstdc++/16844 (Explicit instantiation failing)

	PR libstdc++/16844
	* include/bits/stl_list.h (_M_create_node): Remove unused
	zero-argument version.
	* include/ext/slist (_M_create_node): Pass two arguments to
	allocator's construct() member function.
	* testsuite/23_containers/deque/explicit_instantiation.cc: New.
	* testsuite/23_containers/list/explicit_instantiation.cc: New.
	* testsuite/23_containers/vector/explicit_instantiation.cc: New.
	* testsuite/23_containers/map/explicit_instantiation.cc: New.
	* testsuite/23_containers/set/explicit_instantiation.cc: New.
	* testsuite/23_containers/multimap/explicit_instantiation.cc: New.
	* testsuite/23_containers/multiset/explicit_instantiation.cc: New.
	* testsuite/ext/hash_set_explicit_instantiation.cc: New.
	* testsuite/ext/slist_explicit_instantiation.cc: New.

From-SVN: r85428
---
 libstdc++-v3/ChangeLog                        | 17 ++++++++++
 libstdc++-v3/include/bits/stl_list.h          | 22 ------------
 libstdc++-v3/include/ext/slist                |  2 +-
 .../deque/explicit_instantiation.cc           | 34 +++++++++++++++++++
 .../list/explicit_instantiation.cc            | 34 +++++++++++++++++++
 .../map/explicit_instantiation.cc             | 34 +++++++++++++++++++
 .../multimap/explicit_instantiation.cc        | 34 +++++++++++++++++++
 .../multiset/explicit_instantiation.cc        | 34 +++++++++++++++++++
 .../set/explicit_instantiation.cc             | 34 +++++++++++++++++++
 .../vector/explicit_instantiation.cc          | 34 +++++++++++++++++++
 .../ext/hash_set_explicit_instantiation.cc    | 34 +++++++++++++++++++
 .../ext/slist_explicit_instantiation.cc       | 34 +++++++++++++++++++
 12 files changed, 324 insertions(+), 23 deletions(-)
 create mode 100644 libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/23_containers/list/explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/23_containers/map/explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/23_containers/set/explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/ext/hash_set_explicit_instantiation.cc
 create mode 100644 libstdc++-v3/testsuite/ext/slist_explicit_instantiation.cc

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f56c60f50931..7c4c82cd83df 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,20 @@
+2004-08-01  Matt Austern  <austern@apple.com>
+
+	PR libstdc++/16844
+	* include/bits/stl_list.h (_M_create_node): Remove unused 
+	zero-argument version.
+	* include/ext/slist (_M_create_node): Pass two arguments to
+	allocator's construct() member function.
+	* testsuite/23_containers/deque/explicit_instantiation.cc: New.
+	* testsuite/23_containers/list/explicit_instantiation.cc: New.
+	* testsuite/23_containers/vector/explicit_instantiation.cc: New.
+	* testsuite/23_containers/map/explicit_instantiation.cc: New.
+	* testsuite/23_containers/set/explicit_instantiation.cc: New.
+	* testsuite/23_containers/multimap/explicit_instantiation.cc: New.
+	* testsuite/23_containers/multiset/explicit_instantiation.cc: New.
+	* testsuite/ext/hash_set_explicit_instantiation.cc: New.
+	* testsuite/ext/slist_explicit_instantiation.cc: New.
+	
 2004-07-30  Paolo Carlini  <pcarlini@suse.de>
 
 	* include/bits/locale_facets.tcc (num_get<>::_M_extract_float,
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index 49df1093ab52..c46fd7400a71 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -445,28 +445,6 @@ namespace _GLIBCXX_STD
 	return __p;
       }
 
-      /**
-       *  @if maint
-       *  Allocates space for a new node and default-constructs a new
-       *  instance of @c value_type in it.
-       *  @endif
-       */
-      _Node*
-      _M_create_node()
-      {
-	_Node* __p = this->_M_get_node();
-	try
-	  {
-	    this->get_allocator().construct(&__p->_M_data);
-	  }
-	catch(...)
-	  {
-	    _M_put_node(__p);
-	    __throw_exception_again;
-	  }
-	return __p;
-      }
-
     public:
       // [23.2.2.1] construct/copy/destroy
       // (assign() and get_allocator() are also listed in this section)
diff --git a/libstdc++-v3/include/ext/slist b/libstdc++-v3/include/ext/slist
index 470e7a98718c..2e39624317c8 100644
--- a/libstdc++-v3/include/ext/slist
+++ b/libstdc++-v3/include/ext/slist
@@ -344,7 +344,7 @@ namespace __gnu_cxx
 	_Node* __node = this->_M_get_node();
 	try
 	  {
-	    get_allocator().construct(&__node->_M_data);
+	    get_allocator().construct(&__node->_M_data, value_type());
 	    __node->_M_next = 0;
 	  }
 	catch(...)
diff --git a/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation.cc
new file mode 100644
index 000000000000..e6e758d0c74b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <deque>
+
+// { dg-do compile }
+
+template class std::deque<int>;
diff --git a/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation.cc
new file mode 100644
index 000000000000..2c9db8d3f866
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <list>
+
+// { dg-do compile }
+
+template class std::list<int>;
diff --git a/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation.cc
new file mode 100644
index 000000000000..4ceb25015693
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <map>
+
+// { dg-do compile }
+
+template class std::map<int, double>;
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation.cc
new file mode 100644
index 000000000000..4a740b250f67
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <map>
+
+// { dg-do compile }
+
+template class std::multimap<int, double>;
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation.cc
new file mode 100644
index 000000000000..fb6b5f1db191
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <set>
+
+// { dg-do compile }
+
+template class std::multiset<int>;
diff --git a/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation.cc
new file mode 100644
index 000000000000..02e33be0456d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <set>
+
+// { dg-do compile }
+
+template class std::set<int>;
diff --git a/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation.cc
new file mode 100644
index 000000000000..0668bbd12abd
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <vector>
+
+// { dg-do compile }
+
+template class std::vector<int>;
diff --git a/libstdc++-v3/testsuite/ext/hash_set_explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/hash_set_explicit_instantiation.cc
new file mode 100644
index 000000000000..e59a15250086
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/hash_set_explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <ext/hash_set>
+
+// { dg-do compile }
+
+template class __gnu_cxx::hash_set<int>;
diff --git a/libstdc++-v3/testsuite/ext/slist_explicit_instantiation.cc b/libstdc++-v3/testsuite/ext/slist_explicit_instantiation.cc
new file mode 100644
index 000000000000..e31f526380ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/slist_explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2004 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 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.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file tests explicit instantiation of library containers
+
+#include <ext/slist>
+
+// { dg-do compile }
+
+template class __gnu_cxx::slist<int>;
-- 
GitLab