OSDN Git Service

2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Jan 2010 13:01:24 +0000 (13:01 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 Jan 2010 13:01:24 +0000 (13:01 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155733 138bc75d-0d04-0410-961f-82ee72b054a4

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 2f8dab5..11e3843 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 c678984..142aa08 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 334fee5..283224d 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 8d24758..e82b890 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 87dbb0b..6227a1f 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 647d547..d327fc2 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 a68e956..ab21a94 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 d6078f5..bb9aef9 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 942afaa..607d961 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 2445b3d..67733bc 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 183d037..d1a4afb 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 33bf72b..d0859a4 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 48a4eea..0b1d752 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 0b948ae..0ab463d 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 2f88aa8..f526563 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 3895d1e..4ef1fc1 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 50d8d46..df83756 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 5bff1fe..8bab737 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 a50f522..0ff3d3b 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 a871cec..3f51e0d 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 d079335..f710a58 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;
+}