]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/42573 ([C++0x] shrink_to_fit() missing)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 8 Jan 2010 13:01:24 +0000 (13:01 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 8 Jan 2010 13:01:24 +0000 (13:01 +0000)
2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>

PR libstdc++/42573
* include/bits/allocator.h (struct __shrink_to_fit): Add.
* include/bits/stl_deque.h (deque<>::shrink_to_fit): Add.
* include/bits/stl_vector.h (vector<>::shrink_to_fit): Likewise.
* include/bits/stl_bvector.h (vector<bool>::shrink_to_fit): Likewise.
* include/bits/basic_string.h (basic_string<>::shrink_to_fit):
Likewise.
* include/ext/vstring.h (__versa_string<>::shrink_to_fit): Likewise.
* include/debug/deque: Add corresponding using declaration.
* include/debug/vector: Likewise.
* include/debug/string: Likewise.
* include/profile/deque: Likewise.
* include/profile/vector: Likewise.
* config/abi/pre/gnu.ver: Export new symbols.
* testsuite/23_containers/deque/capacity/shrink_to_fit.cc: New.
* testsuite/23_containers/vector/capacity/shrink_to_fit.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc:
Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc:
Likewise.
* testsuite/ext/vstring/capacity/shrink_to_fit.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.

From-SVN: r155733

26 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/stl_bvector.h
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/debug/deque
libstdc++-v3/include/debug/string
libstdc++-v3/include/debug/vector
libstdc++-v3/include/ext/vstring.h
libstdc++-v3/include/profile/deque
libstdc++-v3/include/profile/vector
libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc [new file with mode: 0644]
libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc
libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc [new file with mode: 0644]

index 2f8dab5bc58e3733b4eb6a00640d77bb6bfbfabc..11e38434525d2c4a1bbd536c9a2945d9206cb3af 100644 (file)
@@ -1,3 +1,43 @@
+2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR libstdc++/42573
+       * include/bits/allocator.h (struct __shrink_to_fit): Add.
+       * include/bits/stl_deque.h (deque<>::shrink_to_fit): Add.
+       * include/bits/stl_vector.h (vector<>::shrink_to_fit): Likewise.
+       * include/bits/stl_bvector.h (vector<bool>::shrink_to_fit): Likewise.
+       * include/bits/basic_string.h (basic_string<>::shrink_to_fit):
+       Likewise.
+       * include/ext/vstring.h (__versa_string<>::shrink_to_fit): Likewise.
+       * include/debug/deque: Add corresponding using declaration.
+       * include/debug/vector: Likewise.
+       * include/debug/string: Likewise.
+       * include/profile/deque: Likewise.
+       * include/profile/vector: Likewise.
+       * config/abi/pre/gnu.ver: Export new symbols.
+       * testsuite/23_containers/deque/capacity/shrink_to_fit.cc: New.
+       * testsuite/23_containers/vector/capacity/shrink_to_fit.cc: Likewise.
+       * testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc:
+       Likewise.
+       * testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc:
+       Likewise.
+       * testsuite/ext/vstring/capacity/shrink_to_fit.cc: Likewise.
+       * testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
+       Adjust dg-error line number.
+       * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
+       Likewise.
+       * testsuite/23_containers/deque/requirements/dr438/
+       constructor_1_neg.cc: Likewise.
+       * testsuite/23_containers/deque/requirements/dr438/
+       constructor_2_neg.cc: Likewise.
+       * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
+       Adjust dg-error line number.
+       * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
+       Likewise.
+       * testsuite/23_containers/vector/requirements/dr438/
+       constructor_1_neg.cc: Likewise.
+       * testsuite/23_containers/vector/requirements/dr438/
+       constructor_2_neg.cc: Likewise.
+
 2010-01-07  Benjamin Kosnik  <bkoz@redhat.com>
 
        * doc/xml/manual/evolution.xml: Fix typos, update.
index c67898404fb374b49a029275de0bfe52f386d090..142aa089827913451eb6f41f7e32c74b9a27f7d6 100644 (file)
@@ -1094,6 +1094,10 @@ GLIBCXX_3.4.14 {
     _ZNSs18_S_construct_aux_2*;
     _ZNSbIwSt11char_traitsIwESaIwEE18_S_construct_aux_2*;
 
+    # string|wstring shrink_to_fit member function
+    _ZNSs13shrink_to_fitEv;
+    _ZNSbIwSt11char_traitsIwESaIwEE13shrink_to_fitEv;
+
     _ZSt25__throw_bad_function_callv;
 
     # std::time_get::_M_extract_wday_or_month
index 334fee5d17bf31bce4c8f6bd2579207f5b08476e..283224d66750bc77333957626844eecd6dcb17d0 100644 (file)
@@ -1,6 +1,6 @@
 // Allocators -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -176,6 +176,31 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       { return __one != __two; }
     };
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+   // A very basic implementation for now.  In general we have to wait for
+   // the availability of the infrastructure described in N2983:  we should
+   // try when either T has a move constructor which cannot throw or T is
+   // CopyContructible.
+   // NB: This code doesn't properly belong here, we should find a more
+   // suited place common to std::vector and std::deque.
+   template<typename _Tp,
+           bool = __has_trivial_copy(typename _Tp::value_type)>
+     struct __shrink_to_fit
+     { static void _S_do_it(_Tp&) { } };
+
+   template<typename _Tp>
+     struct __shrink_to_fit<_Tp, true>
+     {
+       static void
+       _S_do_it(_Tp& __v)
+       {
+        try
+          { _Tp(__v).swap(__v); }
+        catch(...) { }
+       }
+     };
+#endif
+
 _GLIBCXX_END_NAMESPACE
 
 #endif
index 8d24758d47cc80e2c2b509f24c6ea56650d6c1b3..e82b8900111a1ff16d439aa4e6f1592ebfe254e7 100644 (file)
@@ -670,7 +670,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       length() const
       { return _M_rep()->_M_length; }
 
-      /// Returns the size() of the largest possible %string.
+      ///  Returns the size() of the largest possible %string.
       size_type
       max_size() const
       { return _Rep::_S_max_size; }
@@ -702,6 +702,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       resize(size_type __n)
       { this->resize(__n, _CharT()); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      ///  A non-binding request to reduce capacity() to size().
+      void
+      shrink_to_fit()
+      {
+       try
+         { reserve(0); }
+       catch(...)
+         { }
+      }
+#endif
+
       /**
        *  Returns the total number of characters that the %string can hold
        *  before needing to allocate more memory.
index 87dbb0b3f87c955660b59249413be9c7223fbb70..6227a1fe951df54e116c25357e1d326c744b2db9 100644 (file)
@@ -1,6 +1,6 @@
 // vector<bool> specialization -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -600,7 +600,7 @@ template<typename _Alloc>
     assign(initializer_list<bool> __l)
     { this->assign(__l.begin(), __l.end()); }
 #endif
-    
+
     iterator
     begin()
     { return this->_M_impl._M_start; }
@@ -824,6 +824,12 @@ template<typename _Alloc>
         insert(end(), __new_size - size(), __x);
     }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    void
+    shrink_to_fit()
+    { std::__shrink_to_fit<vector>::_S_do_it(*this); }
+#endif
+
     void
     flip()
     {
index 647d5476874381652dc559710acdf0049095fcf0..d327fc2f20272d2530144fc3275363f66ff23ab0 100644 (file)
@@ -1,6 +1,6 @@
 // Deque implementation -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -1105,6 +1105,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
          insert(this->_M_impl._M_finish, __new_size - __len, __x);
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**  A non-binding request to reduce memory use.  */
+      void
+      shrink_to_fit()
+      { std::__shrink_to_fit<deque>::_S_do_it(*this); }
+#endif
+
       /**
        *  Returns true if the %deque is empty.  (Thus begin() would
        *  equal end().)
index a68e9560816062234b90ef9e8c7aac6301de3853..ab21a94e530bfe4ff2ca77f8c05c189975695375 100644 (file)
@@ -1,6 +1,6 @@
 // Vector implementation -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -557,6 +557,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
          insert(end(), __new_size - size(), __x);
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**  A non-binding request to reduce capacity() to size().  */
+      void
+      shrink_to_fit()
+      { std::__shrink_to_fit<vector>::_S_do_it(*this); }
+#endif
+
       /**
        *  Returns the total number of elements that the %vector can
        *  hold before needing to allocate more memory.
index d6078f580e1504328fe3e3142e3fa8f9e8a19a64..bb9aef9302d64ae15de18e15c6fb56b48b04a40a 100644 (file)
@@ -1,6 +1,6 @@
 // Debugging deque implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -223,6 +223,10 @@ namespace __debug
          this->_M_invalidate_all();
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      using _Base::shrink_to_fit;
+#endif
+
       using _Base::empty;
 
       // element access:
index 942afaa8337b93475cd79808a198d196985d1eed..607d961171e01e6c6528bcf4255b1c7297246bac 100644 (file)
@@ -1,6 +1,6 @@
 // Debugging string implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2005, 2006, 2009
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -203,6 +203,10 @@ namespace __gnu_debug
     resize(size_type __n)
     { this->resize(__n, _CharT()); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    using _Base::shrink_to_fit;
+#endif
+
     using _Base::capacity;
     using _Base::reserve;
 
index 2445b3d6890f7fae2f7f54960b3babbb7ca4d06d..67733bca9f9e489c5aab9f5601793051f3b9a0e9 100644 (file)
@@ -1,6 +1,6 @@
 // Debugging vector implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -236,6 +236,10 @@ namespace __debug
          this->_M_invalidate_all();
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      using _Base::shrink_to_fit;
+#endif
+
       size_type
       capacity() const
       {
index 183d037a2d214a78ac1566974f3b43cbcfc9ea52..d1a4afba139928d973089cf0a9cc123fd3d1f705 100644 (file)
@@ -1,6 +1,7 @@
 // Versatile string -*- C++ -*-
 
-// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+// 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
@@ -49,7 +50,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
     class __versa_string
     : private _Base<_CharT, _Traits, _Alloc>
     {
-      typedef _Base<_CharT, _Traits, _Alloc>                __vstring_base;      
+      typedef _Base<_CharT, _Traits, _Alloc>                __vstring_base;    
       typedef typename __vstring_base::_CharT_alloc_type    _CharT_alloc_type;
 
       // Types:
@@ -455,6 +456,18 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
       resize(size_type __n)
       { this->resize(__n, _CharT()); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /// A non-binding request to reduce capacity() to size().
+      void
+      shrink_to_fit()
+      {
+       try
+         { this->reserve(0); }
+       catch(...)
+         { }
+      }
+#endif
+
       /**
        *  Returns the total number of characters that the %string can
        *  hold before needing to allocate more memory.
index 33bf72bc784483cb374bbc148508b2d14efa6561..d0859a4aa968fca3a0c62b04f7dbdca1d23b690a 100644 (file)
@@ -1,6 +1,6 @@
 // Profiling deque implementation -*- C++ -*-
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010 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
@@ -200,6 +200,10 @@ namespace __profile
        _Base::resize(__sz, __c);
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      using _Base::shrink_to_fit;
+#endif
+
       using _Base::empty;
 
       // element access:
index 48a4eea4bbe6b4786baa894c05863bb43e81d5fa..0b1d752693531d2f29bdb5933daf23b628937eca 100644 (file)
@@ -1,6 +1,6 @@
 // Profiling vector implementation -*- C++ -*-
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010 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
@@ -169,6 +169,10 @@ namespace __profile
         _Base::resize(__sz, __c);
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      using _Base::shrink_to_fit;
+#endif
+
       using _Base::empty;
 
       // element access:
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc
new file mode 100644 (file)
index 0000000..666445a
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 Pred 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::string s(100, 'a');
+  s.push_back('b');
+  s.push_back('b');
+  VERIFY( s.size() < s.capacity() );
+  s.shrink_to_fit();
+  VERIFY( s.size() == s.capacity() );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc
new file mode 100644 (file)
index 0000000..9fce440
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 Pred 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::wstring s(100, L'a');
+  s.push_back(L'b');
+  s.push_back(L'b');
+  VERIFY( s.size() < s.capacity() );
+  s.shrink_to_fit();
+  VERIFY( s.size() == s.capacity() );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc
new file mode 100644 (file)
index 0000000..5f7fac6
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 Pred 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/>.
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::vector<int> d(100);
+  d.push_back(1);
+  d.push_back(1);
+  // VERIFY( d.size() < d.capacity() );
+  d.shrink_to_fit();
+  // VERIFY( d.size() == d.capacity() );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 0b948aed7fbf426e3e2808662507d86514395d78..0ab463da8216e02639cb6a8983847cf0e58beb56 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1568 }
+// { dg-error "no matching" "" { target *-*-* } 1575 }
 // { dg-excess-errors "" }
 
 #include <deque>
index 2f88aa8eb8035d3a88237f97130975dc432eea95..f5265634130e2ed6d5bcde96cd0ee08bfa6148e2 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1507 }
+// { dg-error "no matching" "" { target *-*-* } 1514 }
 // { dg-excess-errors "" }
 
 #include <deque>
index 3895d1e875866c350470381fdc56003a73c44d89..4ef1fc1b92d8e05d4f49d6b9c13a771ab2468d03 100644 (file)
@@ -18,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1507 }
+// { dg-error "no matching" "" { target *-*-* } 1514 }
 // { dg-excess-errors "" }
 
 #include <deque>
index 50d8d4657a13b416a69c8fd4507d027ac5e9f839..df837568c6880375c2b2ab3fcbb5bbdfbd04f81d 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1652 }
+// { dg-error "no matching" "" { target *-*-* } 1659 }
 // { dg-excess-errors "" }
 
 #include <deque>
diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc
new file mode 100644 (file)
index 0000000..2a73789
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 Pred 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/>.
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::vector<int> v(100);
+  v.push_back(1);
+  v.push_back(1);
+  VERIFY( v.size() < v.capacity() );
+  v.shrink_to_fit();
+  VERIFY( v.size() == v.capacity() );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}
index 5bff1fec07bf00679f2e11386e0e0976ce02ae28..8bab7374da96705cdfbf754cbec466fce827ada2 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1047 }
+// { dg-error "no matching" "" { target *-*-* } 1054 }
 // { dg-excess-errors "" }
 
 #include <vector>
index a50f5226c0763e2e9423d77fd9214a2a4dd61431..0ff3d3b5dbc876a7b47f978583faac9739161553 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 987 }
+// { dg-error "no matching" "" { target *-*-* } 994 }
 // { dg-excess-errors "" }
 
 #include <vector>
index a871cec9b5695e90b1be79dbef8260f0a51d6a71..3f51e0db49a4400b00d75d9d43b6ece0c9ee2244 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 987 }
+// { dg-error "no matching" "" { target *-*-* } 994 }
 // { dg-excess-errors "" }
 
 #include <vector>
index d079335f7ae7b4a77cf5665ffc8b581b09ff5272..f710a584a6c747e8bbe9ab895a75d87052505076 100644 (file)
@@ -1,6 +1,6 @@
 // 2007-04-27  Paolo Carlini  <pcarlini@suse.de>
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation
+// Copyright (C) 2007, 2008, 2009, 2010 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,7 +18,7 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1088 }
+// { dg-error "no matching" "" { target *-*-* } 1095 }
 // { dg-excess-errors "" }
 
 #include <vector>
diff --git a/libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc b/libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc
new file mode 100644 (file)
index 0000000..e6737de
--- /dev/null
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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 Pred 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/>.
+
+#include <ext/vstring.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  __gnu_cxx::__vstring vs(100, 'a');
+  vs.push_back('b');
+  vs.push_back('b');
+  VERIFY( vs.size() < vs.capacity() );
+  vs.shrink_to_fit();
+  VERIFY( vs.size() == vs.capacity() );
+}
+
+int main()
+{
+  test01();
+  return 0;
+}