From 42ca0438ce1cbbd45e4ea07515ab7ee8e1aa7d06 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Wed, 17 Apr 2002 06:20:20 +0000 Subject: [PATCH] concept-inst.cc (vector): Remove instantiations. 2002-04-16 Benjamin Kosnik * src/concept-inst.cc (vector): Remove instantiations. * src/stl-inst.cc (vector::_M_insert_aux): Remove instantiation. (__malloc_alloc_template): Conditionalize. * include/bits/istream.tcc: Remove sputbackc calls. * testsuite/19_diagnostics/stdexceptions.cc: Fix comment. From-SVN: r52405 --- libstdc++-v3/ChangeLog | 11 ++ libstdc++-v3/include/bits/istream.tcc | 137 ++++++------------ libstdc++-v3/src/concept-inst.cc | 51 +------ libstdc++-v3/src/stl-inst.cc | 10 +- .../testsuite/19_diagnostics/stdexceptions.cc | 4 +- 5 files changed, 63 insertions(+), 150 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 632ea3d5469..26af65c93d6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,4 +1,15 @@ +2002-04-16 Benjamin Kosnik + + * src/concept-inst.cc (vector): Remove instantiations. + * src/stl-inst.cc (vector::_M_insert_aux): Remove instantiation. + (__malloc_alloc_template): Conditionalize. + + * include/bits/istream.tcc: Remove sputbackc calls. + + * testsuite/19_diagnostics/stdexceptions.cc: Fix comment. + 2002-04-16 Paolo Carlini + * testsuite/24_iterators/rel_ops.cc: New test. 2002-04-16 Gabriel Dos Reis diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 7f985594f9b..9ee38a42fc7 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -579,28 +579,22 @@ namespace std { _M_gcount = 0; sentry __cerb(*this, true); - if (__cerb && __n > 1) + if (__cerb) { try { const int_type __idelim = traits_type::to_int_type(__delim); const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); - int_type __c = __sb->sbumpc(); - bool __testdelim = __c == __idelim; - bool __testeof = __c == __eof; + int_type __c = __sb->sgetc(); - while (_M_gcount < __n - 1 && !__testeof && !__testdelim) + while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim) { *__s++ = traits_type::to_char_type(__c); + __c = __sb->snextc(); ++_M_gcount; - __c = __sb->sbumpc(); - __testeof = __c == __eof; - __testdelim = __c == __idelim; } - if (__testdelim || _M_gcount == __n - 1) - __sb->sputbackc(__c); - if (__testeof) + if (__c == __eof) this->setstate(ios_base::eofbit); } catch(exception& __fail) @@ -627,35 +621,29 @@ namespace std sentry __cerb(*this, true); if (__cerb) { - int_type __c; - __streambuf_type* __this_sb = this->rdbuf(); try { const int_type __idelim = traits_type::to_int_type(__delim); const int_type __eof = traits_type::eof(); - __c = __this_sb->sbumpc(); - bool __testdelim = __c == __idelim; - bool __testeof = __c == __eof; - bool __testput = true; + __streambuf_type* __this_sb = this->rdbuf(); + int_type __c = __this_sb->sgetc(); - while (!__testeof && !__testdelim - && (__testput = __sb.sputc(traits_type::to_char_type(__c)) - != __eof)) + while (__c != __eof && __c != __idelim + && (__sb.sputc(traits_type::to_char_type(__c)) != __eof)) { ++_M_gcount; - __c = __this_sb->sbumpc(); - __testeof = __c == __eof; - __testdelim = __c == __idelim; + __c = __this_sb->snextc(); } - if (__testdelim || !__testput) - __this_sb->sputbackc(traits_type::to_char_type(__c)); - if (__testeof) + if (__c == __eof) this->setstate(ios_base::eofbit); } catch(exception& __fail) { - // Exception may result from sputc->overflow. - __this_sb->sputbackc(traits_type::to_char_type(__c)); + // 27.6.1.3 paragraph 1 + // Turn this on without causing an ios::failure to be thrown. + this->setstate(ios_base::badbit); + if ((this->exceptions() & ios_base::badbit) != 0) + __throw_exception_again; } } if (!_M_gcount) @@ -674,33 +662,28 @@ namespace std { try { - __streambuf_type* __sb = this->rdbuf(); - int_type __c = __sb->sbumpc(); - ++_M_gcount; const int_type __idelim = traits_type::to_int_type(__delim); const int_type __eof = traits_type::eof(); - bool __testdelim = __c == __idelim; - bool __testeof = __c == __eof; + __streambuf_type* __sb = this->rdbuf(); + int_type __c = __sb->sgetc(); - while (_M_gcount < __n && !__testeof && !__testdelim) + while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim) { *__s++ = traits_type::to_char_type(__c); - __c = __sb->sbumpc(); + __c = __sb->snextc(); ++_M_gcount; - __testeof = __c == __eof; - __testdelim = __c == __idelim; } - - if (__testeof) - { - --_M_gcount; - this->setstate(ios_base::eofbit); - } - else if (!__testdelim) + if (__c == __eof) + this->setstate(ios_base::eofbit); + else { - --_M_gcount; - __sb->sputbackc(traits_type::to_char_type(__c)); - this->setstate(ios_base::failbit); + if (__c == __idelim) + { + __sb->snextc(); + ++_M_gcount; + } + else + this->setstate(ios_base::failbit); } } catch(exception& __fail) @@ -1102,22 +1085,16 @@ namespace std const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc()); const int_type __eof = _Traits::eof(); __streambuf_type* __sb = __in.rdbuf(); - int_type __c = __sb->sbumpc(); - bool __testeof = __c == __eof; - bool __testsp = __ctype.is(ctype_base::space, __c); + int_type __c = __sb->sgetc(); - while (__extracted < __num - 1 && !__testeof && !__testsp) + while (__extracted < __num - 1 + && __c != __eof && !__ctype.is(ctype_base::space, __c)) { *__s++ = __c; ++__extracted; - __c = __sb->sbumpc(); - __testeof = __c == __eof; - __testsp = __ctype.is(ctype_base::space, __c); + __c = __sb->snextc(); } - - if (!__testeof) - __sb->sputbackc(__c); - else + if (__c == __eof) __in.setstate(ios_base::eofbit); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS @@ -1149,26 +1126,15 @@ namespace std typedef typename __istream_type::__streambuf_type __streambuf_type; typedef typename __istream_type::__ctype_type __ctype_type; typedef typename __istream_type::int_type __int_type; - typedef typename __istream_type::char_type __char_type; const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc()); - __streambuf_type* __sb = __in.rdbuf(); const __int_type __eof = _Traits::eof(); - __int_type __c; - bool __testeof; - bool __testsp; - - do - { - __c = __sb->sbumpc(); - __testeof = __c == __eof; - __testsp = __ctype.is(ctype_base::space, __c); - } - while (!__testeof && __testsp); + __streambuf_type* __sb = __in.rdbuf(); + __int_type __c = __sb->sgetc(); - if (!__testeof && !__testsp) - __sb->sputbackc(__c); - else + while (__c != __eof && __ctype.is(ctype_base::space, __c)) + __c = __sb->snextc(); + if (__c == __eof) __in.setstate(ios_base::eofbit); return __in; @@ -1199,21 +1165,16 @@ namespace std const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc()); const __int_type __eof = _Traits::eof(); __streambuf_type* __sb = __in.rdbuf(); - __int_type __c = __sb->sbumpc(); - bool __testeof = __c == __eof; - bool __testsp = __ctype.is(ctype_base::space, __c); - - while (__extracted < __n && !__testeof && !__testsp) + __int_type __c = __sb->sgetc(); + + while (__extracted < __n + && __c != __eof && !__ctype.is(ctype_base::space, __c)) { __str += _Traits::to_char_type(__c); ++__extracted; - __c = __sb->sbumpc(); - __testeof = __c == __eof; - __testsp = __ctype.is(ctype_base::space, __c); + __c = __sb->snextc(); } - if (!__testeof) - __sb->sputbackc(__c); - else + if (__c == __eof) __in.setstate(ios_base::eofbit); __in.width(0); } @@ -1250,17 +1211,15 @@ namespace std __int_type __c = __sb->sbumpc(); const __int_type __eof = _Traits::eof(); __testdelim = __c == __idelim; - bool __testeof = __c == __eof; - while (__extracted <= __n && !__testeof && !__testdelim) + while (__extracted <= __n && __c != __eof && !__testdelim) { __str += _Traits::to_char_type(__c); ++__extracted; __c = __sb->sbumpc(); - __testeof = __c == __eof; __testdelim = __c == __idelim; } - if (__testeof) + if (__c == __eof) __in.setstate(ios_base::eofbit); } if (!__extracted && !__testdelim) diff --git a/libstdc++-v3/src/concept-inst.cc b/libstdc++-v3/src/concept-inst.cc index a467a810c81..01cc030da8d 100644 --- a/libstdc++-v3/src/concept-inst.cc +++ b/libstdc++-v3/src/concept-inst.cc @@ -1,6 +1,6 @@ // Concept checking instantiations -*- C++ -*- -// Copyright (C) 2001 Free Software Foundation +// Copyright (C) 2001, 2002 Free Software Foundation // // This file is part of GNU CC. // @@ -40,7 +40,6 @@ #ifdef _GLIBCPP_CONCEPT_CHECKS #include -#include #include #define _Instantiate(...) template void __function_requires< __VA_ARGS__ > () @@ -49,36 +48,12 @@ namespace __gnu_cxx { template void __aux_require_boolean_expr(bool const&); - _Instantiate(_BidirectionalIteratorConcept< - __normal_iterator< std::locale::facet**, - std::vector > > > ); - - _Instantiate(_BidirectionalIteratorConcept< - __normal_iterator< unsigned*, - std::vector > > > ); - - _Instantiate(_ConvertibleConcept ); - _Instantiate(_ConvertibleConcept ); _Instantiate(_InputIteratorConcept ); _Instantiate(_InputIteratorConcept ); - _Instantiate(_InputIteratorConcept ); - - _Instantiate(_InputIteratorConcept< - __normal_iterator< std::locale::facet* const*, - std::vector > > > ); - - _Instantiate(_InputIteratorConcept< - __normal_iterator< std::locale::facet**, - std::vector > > > ); - - _Instantiate(_InputIteratorConcept< - __normal_iterator< unsigned*, - std::vector > > > ); - #ifdef _GLIBCPP_USE_WCHAR_T _Instantiate(_InputIteratorConcept ); @@ -97,29 +72,6 @@ namespace __gnu_cxx _Instantiate(_LessThanComparableConcept ); - _Instantiate(_Mutable_BidirectionalIteratorConcept< - __normal_iterator< std::locale::facet**, - std::vector > > > ); - - _Instantiate(_Mutable_BidirectionalIteratorConcept< - __normal_iterator< unsigned*, - std::vector > > > ); - - _Instantiate(_Mutable_ForwardIteratorConcept< - __normal_iterator< std::locale::facet**, - std::vector > > > ); - - _Instantiate(_OutputIteratorConcept< - std::locale::facet**, std::locale::facet*> ); - - _Instantiate(_OutputIteratorConcept< - __normal_iterator< std::locale::facet**, - std::vector > >, - std::locale::facet* > ); - - _Instantiate(_OutputIteratorConcept<__normal_iterator< - unsigned*, std::vector > >, unsigned> ); - _Instantiate(_OutputIteratorConcept >, char> ); @@ -153,7 +105,6 @@ namespace __gnu_cxx _Instantiate(_RandomAccessIteratorConcept ); #endif - } // namespace __gnu_cxx #undef _Instantiate diff --git a/libstdc++-v3/src/stl-inst.cc b/libstdc++-v3/src/stl-inst.cc index 94d26b33d23..d8879a7bccd 100644 --- a/libstdc++-v3/src/stl-inst.cc +++ b/libstdc++-v3/src/stl-inst.cc @@ -33,21 +33,15 @@ #include #include -#include namespace std { template class allocator; template class allocator; +#ifdef __USE_MALLOC template class __malloc_alloc_template<0>; - -#ifndef __USE_MALLOC +#else template class __default_alloc_template; #endif - - template - void - vector:: - _M_insert_aux(vector::iterator, unsigned int const &); } // namespace std diff --git a/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc b/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc index c118580ce50..1b11118da5d 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc @@ -1,6 +1,6 @@ // 2001-02-26 Benjamin Kosnik -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002 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 @@ -29,8 +29,6 @@ void test01() { bool test = true; std::string s("lack of sunlight, no water error"); - // XXX work around long-standing, pathalogical, hostility-inducing parser bug - // std::logic_error obj(std::string(strlit)); // 1 std::logic_error obj = std::logic_error(s); -- 2.30.2