From: Paolo Carlini Date: Fri, 8 Jan 2010 13:01:24 +0000 (+0000) Subject: re PR libstdc++/42573 ([C++0x] shrink_to_fit() missing) X-Git-Tag: releases/gcc-4.5.0~1337 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79667f82adf76d79baf6acfa20df02cf7f14d5fc;p=thirdparty%2Fgcc.git re PR libstdc++/42573 ([C++0x] shrink_to_fit() missing) 2010-01-08 Paolo Carlini 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::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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2f8dab5bc58e..11e38434525d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,43 @@ +2010-01-08 Paolo Carlini + + 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::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 * doc/xml/manual/evolution.xml: Fix typos, update. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index c67898404fb3..142aa0898279 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -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 diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 334fee5d17bf..283224d66750 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -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 + struct __shrink_to_fit + { static void _S_do_it(_Tp&) { } }; + + template + struct __shrink_to_fit<_Tp, true> + { + static void + _S_do_it(_Tp& __v) + { + try + { _Tp(__v).swap(__v); } + catch(...) { } + } + }; +#endif + _GLIBCXX_END_NAMESPACE #endif diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 8d24758d47cc..e82b8900111a 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -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. diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 87dbb0b3f87c..6227a1fe951d 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -1,6 +1,6 @@ // vector 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 assign(initializer_list __l) { this->assign(__l.begin(), __l.end()); } #endif - + iterator begin() { return this->_M_impl._M_start; } @@ -824,6 +824,12 @@ template insert(end(), __new_size - size(), __x); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + shrink_to_fit() + { std::__shrink_to_fit::_S_do_it(*this); } +#endif + void flip() { diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 647d54768743..d327fc2f2027 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -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::_S_do_it(*this); } +#endif + /** * Returns true if the %deque is empty. (Thus begin() would * equal end().) diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index a68e95608160..ab21a94e530b 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -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::_S_do_it(*this); } +#endif + /** * Returns the total number of elements that the %vector can * hold before needing to allocate more memory. diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index d6078f580e15..bb9aef9302d6 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -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: diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index 942afaa8337b..607d961171e0 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -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; diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 2445b3d6890f..67733bca9f9e 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -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 { diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index 183d037a2d21..d1a4afba1399 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -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. diff --git a/libstdc++-v3/include/profile/deque b/libstdc++-v3/include/profile/deque index 33bf72bc7844..d0859a4aa968 100644 --- a/libstdc++-v3/include/profile/deque +++ b/libstdc++-v3/include/profile/deque @@ -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: diff --git a/libstdc++-v3/include/profile/vector b/libstdc++-v3/include/profile/vector index 48a4eea4bbe6..0b1d75269353 100644 --- a/libstdc++-v3/include/profile/vector +++ b/libstdc++-v3/include/profile/vector @@ -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 index 000000000000..666445a152d7 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-01-08 Paolo Carlini + +// 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 +// . + +#include +#include + +// 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 index 000000000000..9fce4403ddfa --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-01-08 Paolo Carlini + +// 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 +// . + +#include +#include + +// 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 index 000000000000..5f7fac6df4ad --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-01-08 Paolo Carlini + +// 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 +// . + +#include +#include + +// libstdc++/42573 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector 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; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc index 0b948aed7fbf..0ab463da8216 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -1,6 +1,6 @@ // 2007-04-27 Paolo Carlini -// 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 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1568 } +// { dg-error "no matching" "" { target *-*-* } 1575 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc index 2f88aa8eb803..f5265634130e 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -1,6 +1,6 @@ // 2007-04-27 Paolo Carlini -// 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 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1507 } +// { dg-error "no matching" "" { target *-*-* } 1514 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc index 3895d1e87586..4ef1fc1b92d8 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1507 } +// { dg-error "no matching" "" { target *-*-* } 1514 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc index 50d8d4657a13..df837568c688 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -1,6 +1,6 @@ // 2007-04-27 Paolo Carlini -// 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 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1652 } +// { dg-error "no matching" "" { target *-*-* } 1659 } // { dg-excess-errors "" } #include 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 index 000000000000..2a737891b0aa --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-01-08 Paolo Carlini + +// 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 +// . + +#include +#include + +// libstdc++/42573 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector 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; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc index 5bff1fec07bf..8bab7374da96 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc @@ -1,6 +1,6 @@ // 2007-04-27 Paolo Carlini -// 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 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1047 } +// { dg-error "no matching" "" { target *-*-* } 1054 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc index a50f5226c076..0ff3d3b5dbc8 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc @@ -1,6 +1,6 @@ // 2007-04-27 Paolo Carlini -// 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 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 987 } +// { dg-error "no matching" "" { target *-*-* } 994 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc index a871cec9b569..3f51e0db49a4 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc @@ -1,6 +1,6 @@ // 2007-04-27 Paolo Carlini -// 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 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 987 } +// { dg-error "no matching" "" { target *-*-* } 994 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc index d079335f7ae7..f710a584a6c7 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc @@ -1,6 +1,6 @@ // 2007-04-27 Paolo Carlini -// 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 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1088 } +// { dg-error "no matching" "" { target *-*-* } 1095 } // { dg-excess-errors "" } #include 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 index 000000000000..e6737de0e311 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/capacity/shrink_to_fit.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-01-08 Paolo Carlini + +// 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 +// . + +#include +#include + +// 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; +}