This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] catch tweaks, markup
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 19 Nov 2009 11:27:45 -0800
- Subject: [v3] catch tweaks, markup
Minor markup fixes, tweaks, testsuite deprecated removal.
tested x86_64/linux
-benjamin
2009-11-19 Benjamin Kosnik <bkoz@redhat.com>
* src/pool_allocator.cc: Adjust catch blocks.
* src/bitmap_allocator.cc: Same.
* src/localename.cc: Same.
* src/ios.cc: Same.
* libsupc++/cxxabi-forced.h: Adjust comments, markup.
* testsuite/util/testsuite_hooks.h (copy_constructor::copyCount):
Remove.
(copy_constructor::dtorCount): Remove.
* testsuite/23_containers/list/modifiers/1.h: Adjust.
* testsuite/23_containers/list/modifiers/2.h: Same.
* testsuite/23_containers/list/modifiers/3.h: Same.
Index: src/pool_allocator.cc
===================================================================
--- src/pool_allocator.cc (revision 154338)
+++ src/pool_allocator.cc (working copy)
@@ -94,7 +94,7 @@
{
_S_start_free = static_cast<char*>(::operator new(__bytes_to_get));
}
- __catch (...)
+ __catch(const std::bad_alloc&)
{
// Try to make do with what we have. That can't hurt. We
// do not try smaller requests, since that tends to result
Index: src/bitmap_allocator.cc
===================================================================
--- src/bitmap_allocator.cc (revision 154338)
+++ src/bitmap_allocator.cc (working copy)
@@ -76,7 +76,7 @@
__ret = reinterpret_cast<size_t*>
(::operator new(__sz + sizeof(size_t)));
}
- __catch(...)
+ __catch(const std::bad_alloc&)
{
this->_M_clear();
}
Index: src/localename.cc
===================================================================
--- src/localename.cc (revision 154338)
+++ src/localename.cc (working copy)
@@ -163,7 +163,7 @@
__try
{ _M_impl->_M_replace_categories(__add._M_impl, __cat); }
- __catch (...)
+ __catch(...)
{
_M_impl->_M_remove_reference();
__throw_exception_again;
Index: src/ios.cc
===================================================================
--- src/ios.cc (revision 154338)
+++ src/ios.cc (working copy)
@@ -123,12 +123,12 @@
__newsize = __ix + 1;
__try
{ __words = new _Words[__newsize]; }
- __catch(...)
+ __catch(const std::bad_alloc&)
{
_M_streambuf_state |= badbit;
if (_M_streambuf_state & _M_exception)
__throw_ios_failure(__N("ios_base::_M_grow_words "
- "allocation failed"));
+ "allocation failed"));
if (__iword)
_M_word_zero._M_iword = 0;
else
Index: libsupc++/cxxabi-forced.h
===================================================================
--- libsupc++/cxxabi-forced.h (revision 154338)
+++ libsupc++/cxxabi-forced.h (working copy)
@@ -23,6 +23,10 @@
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
+/** @file cxxabi-forced.h
+ * The header provides an interface to the C++ ABI.
+ */
+
#ifndef _CXXABI_FORCED_H
#define _CXXABI_FORCED_H 1
@@ -41,7 +45,9 @@
class __forced_unwind
{
virtual ~__forced_unwind() throw();
- virtual void __pure_dummy() = 0; // prevent catch by value
+
+ // Prevent catch by value.
+ virtual void __pure_dummy() = 0;
};
}
#endif // __cplusplus
Index: testsuite/23_containers/list/modifiers/1.h
===================================================================
--- testsuite/23_containers/list/modifiers/1.h (revision 154338)
+++ testsuite/23_containers/list/modifiers/1.h (working copy)
@@ -30,6 +30,9 @@
typedef _Tp list_type;
typedef typename list_type::iterator iterator;
typedef typename list_type::value_type value_type;
+
+ using __gnu_test::copy_constructor;
+ using __gnu_test::destructor;
list_type list0301;
value_type::reset();
@@ -37,7 +40,7 @@
// fill insert at beginning of list / empty list
list0301.insert(list0301.begin(), 3, value_type(11)); // should be [11 11 11]
VERIFY(list0301.size() == 3);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
// save iterators to verify post-insert validity
iterator b = list0301.begin();
@@ -48,7 +51,7 @@
value_type::reset();
list0301.insert(list0301.end(), 3, value_type(13)); // should be [11 11 11 13 13 13]
VERIFY(list0301.size() == 6);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
VERIFY(b == list0301.begin() && b->id() == 11);
VERIFY(e == list0301.end());
VERIFY(m->id() == 11);
@@ -58,7 +61,7 @@
value_type::reset();
list0301.insert(m, 3, value_type(12)); // should be [11 11 11 12 12 12 13 13 13]
VERIFY(list0301.size() == 9);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
VERIFY(b == list0301.begin() && b->id() == 11);
VERIFY(e == list0301.end());
VERIFY(m->id() == 13);
@@ -67,7 +70,7 @@
value_type::reset();
m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13]
VERIFY(list0301.size() == 8);
- VERIFY(value_type::dtorCount() == 1);
+ VERIFY(destructor::count() == 1);
VERIFY(b == list0301.begin() && b->id() == 11);
VERIFY(e == list0301.end());
VERIFY(m->id() == 13);
@@ -76,7 +79,7 @@
value_type::reset();
m = list0301.erase(list0301.begin(), m); // should be [13 13]
VERIFY(list0301.size() == 2);
- VERIFY(value_type::dtorCount() == 6);
+ VERIFY(destructor::count() == 6);
VERIFY(m->id() == 13);
// range fill at beginning
@@ -86,14 +89,14 @@
b = list0301.begin();
list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
VERIFY(list0301.size() == 5);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
VERIFY(m->id() == 13);
// range fill at end
value_type::reset();
list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
VERIFY(list0301.size() == 8);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
VERIFY(e == list0301.end());
VERIFY(m->id() == 13);
@@ -101,13 +104,13 @@
value_type::reset();
list0301.insert(m, A, A + N);
VERIFY(list0301.size() == 11);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
VERIFY(e == list0301.end());
VERIFY(m->id() == 13);
value_type::reset();
list0301.clear();
VERIFY(list0301.size() == 0);
- VERIFY(value_type::dtorCount() == 11);
+ VERIFY(destructor::count() == 11);
VERIFY(e == list0301.end());
}
Index: testsuite/23_containers/list/modifiers/2.h
===================================================================
--- testsuite/23_containers/list/modifiers/2.h (revision 154338)
+++ testsuite/23_containers/list/modifiers/2.h (working copy)
@@ -30,16 +30,19 @@
typedef typename list_type::iterator iterator;
typedef typename list_type::const_iterator const_iterator;
+ using __gnu_test::copy_constructor;
+ using __gnu_test::destructor;
+
list_type list0201;
value_type::reset();
list0201.insert(list0201.begin(), value_type(1)); // list should be [1]
VERIFY(list0201.size() == 1);
- VERIFY(value_type::copyCount() == 1);
+ VERIFY(copy_constructor::count() == 1);
list0201.insert(list0201.end(), value_type(2)); // list should be [1 2]
VERIFY(list0201.size() == 2);
- VERIFY(value_type::copyCount() == 2);
+ VERIFY(copy_constructor::count() == 2);
iterator i = list0201.begin();
const_iterator j = i;
@@ -48,7 +51,7 @@
list0201.insert(i, value_type(3)); // list should be [1 3 2]
VERIFY(list0201.size() == 3);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
const_iterator k = i;
VERIFY(i->id() == 2); --i;
@@ -60,27 +63,27 @@
value_type::reset();
list0201.erase(i); // should be [1 2]
VERIFY(list0201.size() == 2);
- VERIFY(value_type::dtorCount() == 1);
+ VERIFY(destructor::count() == 1);
VERIFY(k->id() == 2);
VERIFY(j->id() == 1);
list_type list0202;
value_type::reset();
VERIFY(list0202.size() == 0);
- VERIFY(value_type::copyCount() == 0);
- VERIFY(value_type::dtorCount() == 0);
+ VERIFY(copy_constructor::count() == 0);
+ VERIFY(destructor::count() == 0);
// member swap
list0202.swap(list0201);
VERIFY(list0201.size() == 0);
VERIFY(list0202.size() == 2);
- VERIFY(value_type::copyCount() == 0);
- VERIFY(value_type::dtorCount() == 0);
+ VERIFY(copy_constructor::count() == 0);
+ VERIFY(destructor::count() == 0);
// specialized swap
swap(list0201, list0202);
VERIFY(list0201.size() == 2);
VERIFY(list0202.size() == 0);
- VERIFY(value_type::copyCount() == 0);
- VERIFY(value_type::dtorCount() == 0);
+ VERIFY(copy_constructor::count() == 0);
+ VERIFY(destructor::count() == 0);
}
Index: testsuite/23_containers/list/modifiers/3.h
===================================================================
--- testsuite/23_containers/list/modifiers/3.h (revision 154338)
+++ testsuite/23_containers/list/modifiers/3.h (working copy)
@@ -51,6 +51,9 @@
typedef typename list_type::const_iterator const_iterator;
typedef typename list_type::const_reverse_iterator const_reverse_iterator;
+ using __gnu_test::copy_constructor;
+ using __gnu_test::destructor;
+
list_type list0101;
const_iterator i;
const_reverse_iterator j;
@@ -59,7 +62,7 @@
list0101.push_back(value_type(1)); // list should be [1]
VERIFY(list0101.size() == 1);
- VERIFY(value_type::copyCount() == 1);
+ VERIFY(copy_constructor::count() == 1);
k = list0101.end();
--k;
@@ -69,12 +72,12 @@
list0101.push_front(value_type(2)); // list should be [2 1]
VERIFY(list0101.size() == 2);
- VERIFY(value_type::copyCount() == 2);
+ VERIFY(copy_constructor::count() == 2);
VERIFY(k->id() == 1);
list0101.push_back(value_type(3)); // list should be [2 1 3]
VERIFY(list0101.size() == 3);
- VERIFY(value_type::copyCount() == 3);
+ VERIFY(copy_constructor::count() == 3);
VERIFY(k->id() == 1);
try
@@ -85,7 +88,7 @@
catch (...)
{
VERIFY(list0101.size() == 3);
- VERIFY(value_type::copyCount() == 4);
+ VERIFY(copy_constructor::count() == 4);
}
i = list0101.begin();
@@ -106,13 +109,13 @@
list0101.pop_back(); // list should be [2 1]
VERIFY(list0101.size() == 2);
- VERIFY(value_type::dtorCount() == 1);
+ VERIFY(destructor::count() == 1);
VERIFY(i->id() == 1);
VERIFY(k->id() == 1);
list0101.pop_front(); // list should be [1]
VERIFY(list0101.size() == 1);
- VERIFY(value_type::dtorCount() == 2);
+ VERIFY(destructor::count() == 2);
VERIFY(i->id() == 1);
VERIFY(k->id() == 1);
}
Index: testsuite/util/testsuite_hooks.h
===================================================================
--- testsuite/util/testsuite_hooks.h (revision 154338)
+++ testsuite/util/testsuite_hooks.h (working copy)
@@ -270,11 +270,6 @@
int
id() const { return id_; }
- private:
- int id_;
- const bool throw_on_copy_;
-
- public:
static void
reset()
{
@@ -283,17 +278,9 @@
destructor::reset();
}
- // for backwards-compatibility
- static int
- copyCount()
- { return copy_constructor::count(); }
-
- // for backwards-compatibility
- static int
- dtorCount()
- { return destructor::count(); }
-
private:
+ int id_;
+ const bool throw_on_copy_;
static int next_id_;
};