diff options
author | Paolo Carlini <pcarlini@suse.de> | 2005-12-15 23:57:34 +0000 |
---|---|---|
committer | Paolo Carlini <pcarlini@suse.de> | 2005-12-15 23:57:34 +0000 |
commit | 5c8b84c0cd7a78b921d62460ef5940f1f67893d1 (patch) | |
tree | c55b5d63ed9f9769d988a99dca527559224223e2 | |
parent | 0b73cb629cd8d42597c4f18d0855becdab604e25 (diff) |
2005-12-15 Paolo Carlini <pcarlini@suse.de>
* include/bits/predefined_ops.h (class __bind2nd<_Lhs, _Value,
__gnu_cxx::__ops::equal_to<_Lhs, _Value> >): Fix order of the
arguments.
2005-12-15 Paolo Carlini <pcarlini@suse.de>
Merged to mainline at revision 108592.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/libstdcxx_so_7-branch@108607 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libstdc++-v3/ChangeLog | 193 | ||||
-rw-r--r-- | libstdc++-v3/ChangeLog.libstdcxx_so_7-branch | 10 | ||||
-rw-r--r-- | libstdc++-v3/config/locale/gnu/c_locale.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/docs/html/configopts.html | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/predefined_ops.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_list.h | 106 | ||||
-rw-r--r-- | libstdc++-v3/include/std/std_limits.h | 9 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/22_locale/facet/25421.cc | 67 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc | 92 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/lib/libstdc++.exp | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/testsuite_allocator.h | 77 |
11 files changed, 501 insertions, 65 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d0f773dfb58..92540fba329 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,196 @@ +2005-12-15 Paolo Carlini <pcarlini@suse.de> + + * include/bits/stl_vector.h (vector<>::_M_get_Tp_allocator): Change + to return by ref and add non const version. + * include/bits/stl_deque.h (deque<>::_M_get_Tp_allocator): Likewise. + +2005-12-15 Paolo Carlini <pcarlini@suse.de> + + PR libstdc++/25421 + * config/locale/gnu/c_locale.cc (_S_destroy_c_locale): Check + for null argument. + * testsuite/22_locale/facet/25421.cc: New. + +2005-12-13 Carlos O'Donell <carlos@codesourcery.com> + + * include/std/std_limits.h (struct numeric_limits): + Use __DBL_HAS_DENORM__, __FLT_HAS_DENORM__, __LDBL_HAS_DENORM__. + +2005-12-10 Paolo Carlini <pcarlini@suse.de> + + * include/ext/sso_string_base.h (__sso_string_base<>::_M_compare): + Add, specialized for char and wchar_t to immediately return true + when a string is compared to itself. + * include/ext/rc_string_base.h (__rc_string_base<>::_M_compare): + Likewise, for the same _Rep. + * include/ext/vstring.h (compare(const string&)): Use it. + + * include/ext/sso_string_base.h (__sso_string_base<>::_M_destroy): + Deallocate passed size + 1. + (_M_dispose, _M_reserve): Adjust. + +2005-12-09 Paolo Carlini <pcarlini@suse.de> + Howard Hinnant <hhinnant@apple.com> + + PR libstdc++/25288 + * include/bits/stl_list.h (list<>::_M_insert_dispatch, _M_fill_insert): + Remove. + (_M_initialize_dispatch, _M_fill_initialize): Add. + (list(size_type, const value_type&, const allocator_type&), + list(const list&), list(_InputIterator, _InputIterator, + const allocator_type&): Use the latter. + (insert(iterator, size_type, const value_type&), insert(iterator, + _InputIterator, _InputIterator)): Use construction & splice. + * testsuite/23_containers/list/modifiers/insert/25288.cc: New. + * testsuite/testsuite_allocator.h (class throw_allocator): Add. + + * include/bits/stl_list.h (list<>::insert, erase): Fix wrong comments. + +2005-12-08 Paolo Carlini <pcarlini@suse.de> + + * include/bits/stl_vector.h (vector<>::size, resize, capacity, + operator[]): Avoid troubles with ADL, user defined operators + and __normal_iterator. + (_M_erase_at_end): Fix to take a pointer. + (clear): Adjust call. + * include/bits/vector.tcc (vector<>::insert(iterator, const + value_type&), erase(iterator, iterator), operator=(const + vector<>&), _M_assign_aux(input_iterator_tag), _M_insert_aux, + _M_fill_insert, _M_range_insert): Likewise. + (_M_fill_assign, _M_assign_aux(forward_iterator_tag)): Adjust + _M_erase_at_end call. + * testsuite/23_containers/vector/types/1.cc: New. + +2005-12-08 Paolo Carlini <pcarlini@suse.de> + + PR libstdc++/24617 + * include/bits/stl_vector.h (vector<>::_M_erase_at_end): New. + (vector<>::clear, resize): Use it. + * include/bits/vector.tcc (vector<>::erase(iterator, iterator), + _M_fill_assign, _M_assign_aux): Likewise. + + * testsuite/23_containers/vector/modifiers/erase/1.cc: New. + +2005-12-07 Paolo Carlini <pcarlini@suse.de> + + * docs/html/configopts.html ([--enable-libstdcxx-allocator]): + Mention the SGI pooled allocator. + +2005-12-06 Paolo Carlini <pcarlini@suse.de> + + * include/bits/basic_string.h (insert(iterator, _CharT), + erase(iterator), erase(iterator, iterator)): Avoid troubles + with ADL, user defined operators and __normal_iterator. + * include/bits/stl_iterator.h (operator-(const __normal_iterator + <_Iterator, _Container>&, const __normal_iterator<_Iterator, + _Container>&)): Add overload for left and right iterators of + the same type. + * include/debug/safe_iterator.h (operator-(const _Safe_iterator + <_Iterator, _Sequence>&, const _Safe_iterator<_Iterator, + _Sequence>&)): Likewise. + * testsuite/21_strings/basic_string/types/1.cc: New. + +2005-12-05 Paolo Carlini <pcarlini@suse.de> + + * include/ext/sso_string_base.h (__sso_string_base<>::_M_assign): + Simplify, avoid pointless reallocations. + +2005-12-04 Paolo Carlini <pcarlini@suse.de> + + * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): + Simplify. + +2005-12-04 Paolo Carlini <pcarlini@suse.de> + + * include/ext/vstring.h (__versa_string<>::operator+, all + versions): Move out of line... + * include/ext/vstring.tcc (__versa_string<>::operator+): ... + here; consistently use reserve for the benefit of sso_string_base; + prefer push_back to single-char append when appropriate. + + * include/ext/vstring.h (__versa_string<>::push_back): Don't + call _M_reserve, _M_mutate instead. + (reserve): Just forward to _M_reserve. + * include/ext/vstring.tcc (__versa_string<>::_M_reserve): Remove. + * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): Also + do the initial checks (first on length, in case __res == capacity). + * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve: + Likewise; don't call _M_set_length unnecessarily. + +2005-12-04 Paolo Carlini <pcarlini@suse.de> + + * include/ext/vstring.h (__versa_string<>::_M_append): New. + (append(const __versa_string&), append(const __versa_string&, + size_type, size_type), append(const _CharT*, size_type), + append(const _CharT*)): Use it. + (append(size_type, _CharT)): Delegate to _M_replace_aux. + (assign(const __versa_string&, size_type, size_type), + assign(const _CharT*), replace(size_type, size_type, + const _CharT*, size_type)): Forward to _M_replace. + * include/ext/vstring.tcc (__versa_string<>::_M_append): + Define, core append functionality. + (_M_replace): Simplify, move __s == 0 case to _M_replace_aux. + (_M_replace_aux): Reorganize, don't call _M_replace. + +2005-12-04 Paolo Carlini <pcarlini@suse.de> + + * include/ext/vstring.tcc (__versa_string<>::_M_replace): + Perform _M_check_length at the beginning and remove it from ... + (replace, _M_replace_dispatch, _M_replace_aux, assign): ... here. + (assign): Now move inline. + (resize): Don't call _M_check_length redundantly, append does. + +2005-12-04 Paolo Carlini <pcarlini@suse.de> + + * include/ext/sso_string_base.h (__sso_string_base<>::_M_get_allocator): + Add non const version. + * include/ext/rc_string_base.h (__rc_string_base<>::_M_get_allocator): + Likewise. + + * include/ext/sso_string_base.h (__sso_string_base<>::_M_erase): Add. + * include/ext/rc_string_base.h (__rc_string_base<>::_M_erase): Likewise. + (_M_leak_hard): Use it. + * include/ext/vstring.h (__versa_string<>::clear, erase, all + versions): Use it. + * include/ext/vstring.tcc (__versa_string<>::resize): Likewise. + + * include/ext/vstring.h (__versa_string<>::_M_replace_safe): + Remove. + * include/ext/vstring.h (__versa_string<>::_M_replace): New, does + the in-place work or delegates to _M_mutate in case of reallocation. + * include/ext/vstring.tcc (__versa_string<>::_M_replace_safe): + Remove. + * include/ext/vstring.tcc (__versa_string<>::_M_replace): Define. + (assign, replace, _M_replace_dispatch, _M_replace_aux): Use it. + * include/ext/sso_string_base.h (__sso_string_base<>::_M_mutate): + Change to manage only reallocations. + * include/ext/rc_string_base.h (__rc_string_base<>::_M_mutate): + Likewise. + + * include/ext/vstring.h (__versa_string<>::insert(size_type, + const __versa_string&), insert(size_type, const __versa_string&, + size_type, size_type), insert(size_type, const _CharT*, size_type), + insert(size_type, const _CharT*)): Delegate to replace. + + * include/ext/vstring.h (__versa_string<>::reserve): Move out of + line. + * include/ext/vstring.tcc (__versa_string<>::reserve): Do the + checks and call _M_reserve. + * include/ext/vstring.h (__versa_string<>::append): Call _M_reserve + instead of reserve. + * include/ext/vstring.tcc (__versa_string<>::append, all versions): + Likewise. + * include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve): + Adjust. + * include/ext/rc_string_base.h (__rc_string_base<>::_M_reserve): + Likewise. + +2005-12-02 David Billinghurst (David.Billinghurst@riotinto.com) + + PR testsuite/25193 + * testsuite/lib/libstdc++.exp (libstdc++-dg-test): Catch + error if file cannot be deleted. + 2005-11-23 Paolo Carlini <pcarlini@suse.de> PR libstdc++/24975 (basic_string) diff --git a/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch b/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch index 878654e6b93..b3396f8ec13 100644 --- a/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch +++ b/libstdc++-v3/ChangeLog.libstdcxx_so_7-branch @@ -1,3 +1,13 @@ +2005-12-15 Paolo Carlini <pcarlini@suse.de> + + * include/bits/predefined_ops.h (class __bind2nd<_Lhs, _Value, + __gnu_cxx::__ops::equal_to<_Lhs, _Value> >): Fix order of the + arguments. + +2005-12-15 Paolo Carlini <pcarlini@suse.de> + + Merged to mainline at revision 108592. + 2005-12-15 Chris Jefferson <caj@cs.york.ac.uk> * include/bits/predefined_ops.h (struct less, struct equal_to): diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc index 493ad4b2ca3..7a45a6e9fda 100644 --- a/libstdc++-v3/config/locale/gnu/c_locale.cc +++ b/libstdc++-v3/config/locale/gnu/c_locale.cc @@ -100,7 +100,7 @@ namespace std void locale::facet::_S_destroy_c_locale(__c_locale& __cloc) { - if (_S_get_c_locale() != __cloc) + if (__cloc && _S_get_c_locale() != __cloc) __freelocale(__cloc); } diff --git a/libstdc++-v3/docs/html/configopts.html b/libstdc++-v3/docs/html/configopts.html index 80ff219a974..b396a2d1822 100644 --- a/libstdc++-v3/docs/html/configopts.html +++ b/libstdc++-v3/docs/html/configopts.html @@ -136,9 +136,9 @@ options</a></h1> <dd><p>Select a target-specific underlying std::allocator. The choices are 'new' to specify a wrapper for new, 'malloc' to specify a wrapper for malloc, 'mt' for a fixed power of two allocator - (<a href="ext/mt_allocator.html">documented</a> under extensions) or - 'bitmap' for a bitmap allocator. This option can change the - library ABI. + (<a href="ext/mt_allocator.html">documented</a> under extensions), + 'pool' for the SGI pooled allocator or 'bitmap' for a bitmap allocator. + This option can change the library ABI. </p> </dd> diff --git a/libstdc++-v3/include/bits/predefined_ops.h b/libstdc++-v3/include/bits/predefined_ops.h index 2c528d380e8..8ae65f65a5e 100644 --- a/libstdc++-v3/include/bits/predefined_ops.h +++ b/libstdc++-v3/include/bits/predefined_ops.h @@ -157,7 +157,7 @@ namespace __ops * @endif */ template<typename _Lhs, typename _Value> - class __bind2nd<__gnu_cxx::__ops::equal_to<_Lhs, _Value>, _Lhs, _Value> + class __bind2nd<_Lhs, _Value, __gnu_cxx::__ops::equal_to<_Lhs, _Value> > { const _Value& _M_value; diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index e08fac713f4..3ab11e3cd58 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -480,7 +480,7 @@ namespace _GLIBCXX_STD list(size_type __n, const value_type& __value = value_type(), const allocator_type& __a = allocator_type()) : _Base(__a) - { this->insert(begin(), __n, __value); } + { _M_fill_initialize(__n, __value); } /** * @brief %List copy constructor. @@ -491,7 +491,7 @@ namespace _GLIBCXX_STD */ list(const list& __x) : _Base(__x.get_allocator()) - { this->insert(begin(), __x.begin(), __x.end()); } + { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } /** * @brief %List move constructor @@ -516,17 +516,16 @@ namespace _GLIBCXX_STD * Create a %list consisting of copies of the elements from * [@a first,@a last). This is linear in N (where N is * distance(@a first,@a last)). - * - * @if maint - * We don't need any dispatching tricks here, because insert does all of - * that anyway. - * @endif */ template<typename _InputIterator> list(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) - { this->insert(begin(), __first, __last); } + { + // Check whether it's an integral type. If so, it's not an iterator. + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + _M_initialize_dispatch(__first, __last, _Integral()); + } /** * No explicit dtor needed as the _Base dtor takes care of @@ -831,13 +830,15 @@ namespace _GLIBCXX_STD * This function will insert a specified number of copies of the * given data before the location specified by @a position. * - * Due to the nature of a %list this operation can be done in - * constant time, and does not invalidate iterators and - * references. + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. */ void insert(iterator __position, size_type __n, const value_type& __x) - { _M_fill_insert(__position, __n, __x); } + { + list __tmp(__n, __x, get_allocator()); + splice(__position, __tmp); + } /** * @brief Inserts a range into the %list. @@ -849,18 +850,16 @@ namespace _GLIBCXX_STD * first,@a last) into the %list before the location specified by * @a position. * - * Due to the nature of a %list this operation can be done in - * constant time, and does not invalidate iterators and - * references. + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. */ template<typename _InputIterator> void insert(iterator __position, _InputIterator __first, _InputIterator __last) { - // Check whether it's an integral type. If so, it's not an iterator. - typedef typename std::__is_integer<_InputIterator>::__type _Integral; - _M_insert_dispatch(__position, __first, __last, _Integral()); + list __tmp(__first, __last, get_allocator()); + splice(__position, __tmp); } /** @@ -892,13 +891,12 @@ namespace _GLIBCXX_STD * This function will erase the elements in the range @a * [first,last) and shorten the %list accordingly. * - * Due to the nature of a %list this operation can be done in - * constant time, and only invalidates iterators/references to - * the element being removed. The user is also cautioned that - * this function only erases the elements, and that if the - * elements themselves are pointers, the pointed-to memory is not - * touched in any way. Managing the pointer is the user's - * responsibilty. + * This operation is linear time in the size of the range and only + * invalidates iterators/references to the element being removed. + * The user is also cautioned that this function only erases the + * elements, and that if the elements themselves are pointers, the + * pointed-to memory is not touched in any way. Managing the pointer + * is the user's responsibilty. */ iterator erase(iterator __first, iterator __last) @@ -1104,60 +1102,58 @@ namespace _GLIBCXX_STD sort(_StrictWeakOrdering); protected: - // Internal assign functions follow. + // Internal constructor functions follow. - // Called by the range assign to implement [23.1.1]/9 + // Called by the range constructor to implement [23.1.1]/9 template<typename _Integer> void - _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) + _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { - _M_fill_assign(static_cast<size_type>(__n), - static_cast<value_type>(__val)); + _M_fill_initialize(static_cast<size_type>(__n), + static_cast<value_type>(__x)); } - // Called by the range assign to implement [23.1.1]/9 + // Called by the range constructor to implement [23.1.1]/9 template<typename _InputIterator> void - _M_assign_dispatch(_InputIterator __first, _InputIterator __last, - __false_type); + _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, + __false_type) + { + for (; __first != __last; ++__first) + push_back(*__first); + } - // Called by assign(n,t), and the range assign when it turns out + // Called by list(n,v,a), and the range constructor when it turns out // to be the same thing. void - _M_fill_assign(size_type __n, const value_type& __val); + _M_fill_initialize(size_type __n, const value_type& __x) + { + for (; __n > 0; --__n) + push_back(__x); + } - // Internal insert functions follow. + // Internal assign functions follow. - // Called by the range insert to implement [23.1.1]/9 + // Called by the range assign to implement [23.1.1]/9 template<typename _Integer> void - _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, - __true_type) + _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) { - _M_fill_insert(__pos, static_cast<size_type>(__n), - static_cast<value_type>(__x)); + _M_fill_assign(static_cast<size_type>(__n), + static_cast<value_type>(__val)); } - // Called by the range insert to implement [23.1.1]/9 + // Called by the range assign to implement [23.1.1]/9 template<typename _InputIterator> void - _M_insert_dispatch(iterator __pos, - _InputIterator __first, _InputIterator __last, - __false_type) - { - for (; __first != __last; ++__first) - _M_insert(__pos, *__first); - } + _M_assign_dispatch(_InputIterator __first, _InputIterator __last, + __false_type); - // Called by insert(p,n,x), and the range insert when it turns out + // Called by assign(n,t), and the range assign when it turns out // to be the same thing. void - _M_fill_insert(iterator __pos, size_type __n, const value_type& __x) - { - for (; __n > 0; --__n) - _M_insert(__pos, __x); - } + _M_fill_assign(size_type __n, const value_type& __val); // Moves the elements from [first,last) before position. diff --git a/libstdc++-v3/include/std/std_limits.h b/libstdc++-v3/include/std/std_limits.h index e7c33e5866b..7643dcfe230 100644 --- a/libstdc++-v3/include/std/std_limits.h +++ b/libstdc++-v3/include/std/std_limits.h @@ -1,6 +1,7 @@ // The template and inlines for the -*- C++ -*- numeric_limits classes. -// Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 +// 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 @@ -1007,7 +1008,7 @@ namespace std static const bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__; static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm - = bool(__FLT_DENORM_MIN__) ? denorm_present : denorm_absent; + = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent; static const bool has_denorm_loss = __glibcxx_float_has_denorm_loss; static float infinity() throw() @@ -1064,7 +1065,7 @@ namespace std static const bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__; static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm - = bool(__DBL_DENORM_MIN__) ? denorm_present : denorm_absent; + = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent; static const bool has_denorm_loss = __glibcxx_double_has_denorm_loss; static double infinity() throw() @@ -1121,7 +1122,7 @@ namespace std static const bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__; static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm - = bool(__LDBL_DENORM_MIN__) ? denorm_present : denorm_absent; + = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent; static const bool has_denorm_loss = __glibcxx_long_double_has_denorm_loss; diff --git a/libstdc++-v3/testsuite/22_locale/facet/25421.cc b/libstdc++-v3/testsuite/22_locale/facet/25421.cc new file mode 100644 index 00000000000..93b873fef4b --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/facet/25421.cc @@ -0,0 +1,67 @@ +// 2005-12-15 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 22.1.1.1.2 - class locale::facet [lib.locale.facet] + +#include <stdexcept> +#include <locale> +#include <testsuite_hooks.h> + +// libstdc++/25421 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + try + { + new codecvt_byname<char, char, mbstate_t>("invalid-loc"); + new collate_byname<char>("invalid-loc"); + new ctype_byname<char>("invalid-loc"); + new messages_byname<char>("invalid-loc"); + new moneypunct_byname<char, true>("invalid-loc"); + new numpunct_byname<char>("invalid-loc"); + +#ifdef _GLIBCXX_USE_WCHAR_T + new codecvt_byname<wchar_t, char, mbstate_t>("invalid-loc"); + new collate_byname<wchar_t>("invalid-loc"); + new ctype_byname<wchar_t>("invalid-loc"); + new messages_byname<wchar_t>("invalid-loc"); + new moneypunct_byname<wchar_t, true>("invalid-loc"); + new numpunct_byname<wchar_t>("invalid-loc"); +#endif + } + catch(const std::runtime_error&) + { + // named locale not valid + VERIFY( true ); + } + catch(...) + { + // some other error + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc new file mode 100644 index 00000000000..a2297180d6b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc @@ -0,0 +1,92 @@ +// Copyright (C) 2005 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 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.2.3 list modifiers [lib.list.modifiers] + +#include <list> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// libstdc++/25288 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef __gnu_test::throw_allocator<int> my_alloc; + typedef std::list<int, my_alloc > my_list; + + for (int j = 0; j < 10; ++j) + for (int i = 0; i < 10; ++i) + { + my_alloc alloc1(j + i); + my_list list1(alloc1); + + for (int k = 0; k < j; ++k) + list1.push_back(-(k + 1)); + + try + { + list1.insert(list1.begin(), 10, 99); + VERIFY( false ); + } + catch (std::bad_alloc&) + { + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( list1.size() == my_list::size_type(j) ); + VERIFY( list1.size() == 0 || list1.back() == -j ); + VERIFY( list1.size() == 0 || list1.front() == -1 ); + + my_alloc alloc2(j + i); + my_list list2(alloc2); + + const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + for (int k = 0; k < j; ++k) + list2.push_back(-(k + 1)); + + try + { + list2.insert(list2.begin(), data, data + 10); + VERIFY( false ); + } + catch (std::bad_alloc&) + { + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( list2.size() == my_list::size_type(j) ); + VERIFY( list2.size() == 0 || list2.back() == -j ); + VERIFY( list2.size() == 0 || list2.front() == -1 ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index ee5111dfaf9..0a76734d62b 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -264,7 +264,7 @@ proc libstdc++-dg-test { prog do_what extra_tool_flags } { set output_file "./[file rootname [file tail $prog]].exe" # This is the only place where we care if an executable was # created or not. If it was, dg.exp will try to run it. - remote_file build delete $output_file; + catch { remote_file build delete $output_file } } default { perror "$do_what: not a valid dg-do keyword" diff --git a/libstdc++-v3/testsuite/testsuite_allocator.h b/libstdc++-v3/testsuite/testsuite_allocator.h index e2bcb0b4525..77d54826bb3 100644 --- a/libstdc++-v3/testsuite/testsuite_allocator.h +++ b/libstdc++-v3/testsuite/testsuite_allocator.h @@ -232,6 +232,7 @@ namespace __gnu_test throw; } + // A simple allocator which can be constructed endowed of a given // "personality" (an integer), queried in operator== to simulate the // behavior of realworld "unequal" allocators (i.e., not exploiting @@ -362,6 +363,82 @@ namespace __gnu_test int personality; }; + + template<typename Tp> + class throw_allocator + { + public: + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + typedef Tp* pointer; + typedef const Tp* const_pointer; + typedef Tp& reference; + typedef const Tp& const_reference; + typedef Tp value_type; + + template<typename Tp1> + struct rebind + { typedef throw_allocator<Tp1> other; }; + + throw_allocator() throw() + : count(size_type(-1)) { } + + throw_allocator(size_type c) throw() + : count(c) { } + + template<typename Tp1> + throw_allocator(const throw_allocator<Tp1>& b) throw() + : count(b.get_count()) { } + + size_type get_count() const { return count; } + + pointer + address(reference x) const { return &x; } + + const_pointer + address(const_reference x) const { return &x; } + + pointer + allocate(size_type n, const void* = 0) + { + if (count == 0) + throw std::bad_alloc(); + + if (count != size_type(-1)) + --count; + + return static_cast<Tp*>(::operator new(n * sizeof(Tp))); + } + + void + deallocate(pointer p, size_type) + { ::operator delete(p); } + + size_type + max_size() const throw() + { return size_type(-1) / sizeof(Tp); } + + void + construct(pointer p, const Tp& val) + { ::new(p) Tp(val); } + + void + destroy(pointer p) { p->~Tp(); } + + private: + template<typename Tp1> + friend inline bool + operator==(const throw_allocator&, const throw_allocator<Tp1>&) + { return true; } + + template<typename Tp1> + friend inline bool + operator!=(const throw_allocator&, const throw_allocator<Tp1>&) + { return false; } + + size_type count; + }; + }; // namespace __gnu_test #endif // _GLIBCXX_TESTSUITE_ALLOCATOR_H |