From 4661c8fd43ca731dc06329a1cfb628863075dbb2 Mon Sep 17 00:00:00 2001 From: Paolo Carlini <paolo.carlini@oracle.com> Date: Fri, 10 Oct 2008 12:39:01 +0000 Subject: [PATCH] system_error (native_category): Remove. 2008-10-10 Paolo Carlini <paolo.carlini@oracle.com> * include/std/system_error (native_category): Remove. (posix_category): Add. (error_code::error_code(_ErrorCodeEnum, typename enable_if<>:type*): Fix _M_cat initialization. (error_code::operator=(_ErrorCodeEnum)): Assign _M_cat too. (error_condition::_M_cat, error_condtion::operator= (_ErrorConditionEnum)): Implement resolution of DR 804. (error_condition::error_condition(_ErrorConditionEnum, typename enable_if<>:type*): Fix. (error_condition::clear, error_condition::assign): Implement. (operator==, operator!=): Fix uglification of parameters. (make_error_code, make_error_condition): Define in namespace posix_error. (operator<<(basic_ostream<>&, const error_code&)): Define here. * include/std/ostream (operator<<(basic_ostream<>&, const error_code&)): Do not define here. * testsuite/19_diagnostics/error_condition/cons/1.cc: New. * testsuite/19_diagnostics/error_condition/operators/bool.cc: Likewise. * testsuite/19_diagnostics/error_condition/operators/bool_neg.cc: Likewise. * testsuite/19_diagnostics/error_condition/operators/equal.cc: Likewise. * testsuite/19_diagnostics/error_condition/operators/not_equal.cc: Likewise. * testsuite/19_diagnostics/error_code/cons/1.cc: Tweak. * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Adjust dg-error line numbers. * testsuite/30_threads/unique_lock/locking/2.cc: Tweak. * testsuite/util/testsuite_error.h: Minor tweaks. * testsuite/util/testsuite_hooks.cc: Avoid uninitialized warning. From-SVN: r141039 --- libstdc++-v3/ChangeLog | 34 ++++ libstdc++-v3/include/std/ostream | 11 -- libstdc++-v3/include/std/system_error | 166 +++++++++++------- .../error_category/cons/copy_neg.cc | 2 +- .../19_diagnostics/error_code/cons/1.cc | 2 +- .../19_diagnostics/error_condition/cons/1.cc | 49 ++++++ .../error_condition/operators/bool.cc | 48 +++++ .../error_condition/operators/bool_neg.cc | 33 ++++ .../error_condition/operators/equal.cc | 44 +++++ .../error_condition/operators/not_equal.cc | 44 +++++ .../30_threads/unique_lock/locking/2.cc | 8 +- libstdc++-v3/testsuite/util/testsuite_error.h | 8 +- .../testsuite/util/testsuite_hooks.cc | 3 +- 13 files changed, 365 insertions(+), 87 deletions(-) create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 21b8bc56dbd3..49fcab797f5c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,37 @@ +2008-10-10 Paolo Carlini <paolo.carlini@oracle.com> + + * include/std/system_error (native_category): Remove. + (posix_category): Add. + (error_code::error_code(_ErrorCodeEnum, typename enable_if<>:type*): + Fix _M_cat initialization. + (error_code::operator=(_ErrorCodeEnum)): Assign _M_cat too. + (error_condition::_M_cat, error_condtion::operator= + (_ErrorConditionEnum)): Implement resolution of DR 804. + (error_condition::error_condition(_ErrorConditionEnum, typename + enable_if<>:type*): Fix. + (error_condition::clear, error_condition::assign): Implement. + (operator==, operator!=): Fix uglification of parameters. + (make_error_code, make_error_condition): Define in namespace + posix_error. + (operator<<(basic_ostream<>&, const error_code&)): Define here. + * include/std/ostream (operator<<(basic_ostream<>&, + const error_code&)): Do not define here. + * testsuite/19_diagnostics/error_condition/cons/1.cc: New. + * testsuite/19_diagnostics/error_condition/operators/bool.cc: Likewise. + * testsuite/19_diagnostics/error_condition/operators/bool_neg.cc: + Likewise. + * testsuite/19_diagnostics/error_condition/operators/equal.cc: + Likewise. + * testsuite/19_diagnostics/error_condition/operators/not_equal.cc: + Likewise. + * testsuite/19_diagnostics/error_code/cons/1.cc: Tweak. + * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Adjust + dg-error line numbers. + * testsuite/30_threads/unique_lock/locking/2.cc: Tweak. + + * testsuite/util/testsuite_error.h: Minor tweaks. + * testsuite/util/testsuite_hooks.cc: Avoid uninitialized warning. + 2008-10-10 Chris Fairles <cfairles@gcc.gnu.org> * testsuite/20_util/duration/cons/1.cc: Remove invalid check of diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream index c0120fa2f053..913986ecf49a 100644 --- a/libstdc++-v3/include/std/ostream +++ b/libstdc++-v3/include/std/ostream @@ -45,10 +45,6 @@ #include <ios> #include <bits/ostream_insert.h> -#ifdef __GXX_EXPERIMENTAL_CXX0X__ -# include <system_error> -#endif - _GLIBCXX_BEGIN_NAMESPACE(std) // [27.6.2.1] Template class basic_ostream @@ -535,13 +531,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return (__out << reinterpret_cast<const char*>(__s)); } //@} -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - template<typename _CharT, typename _Traits> - inline basic_ostream<_CharT, _Traits>& - operator<<(basic_ostream<_CharT, _Traits>& __out, const error_code& __e) - { return (__out << __e.category().name() << ':' << __e.value()); } -#endif - // [27.6.2.7] standard basic_ostream manipulators /** * @brief Write a newline and flush the stream. diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index b05858106634..6a09ebf5272e 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -111,8 +111,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const error_category& get_posix_category(); const error_category& get_system_category(); + static const error_category& posix_category = get_posix_category(); static const error_category& system_category = get_system_category(); - static const error_category& native_category = get_posix_category(); /// error_code // Implementation-specific error identification @@ -127,7 +127,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<typename _ErrorCodeEnum> error_code(_ErrorCodeEnum __e, typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0) - : _M_value(__e), _M_cat(&system_category) + : _M_value(__e), _M_cat(&posix_category) { } void @@ -144,10 +144,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_cat = &system_category; } + // DR 804. template<typename _ErrorCodeEnum> - typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type& + typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value, + error_code&>::type operator=(_ErrorCodeEnum __e) - { _M_value = __e; } + { + _M_value = __e; + _M_cat = &posix_category; + return *this; + } int value() const { return _M_value; } @@ -172,55 +178,73 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator __bool_type() const { return _M_value != 0 ? &__not_bool_type : false; } + // DR 804. private: int _M_value; const error_category* _M_cat; }; - error_code - make_error_code(posix_error::posix_errno); - // 19.4.2.5 non-member functions - bool operator<(const error_code& lhs, const error_code& rhs); + inline bool + operator<(const error_code& __lhs, const error_code& __rhs) + { + return (__lhs.category() < __rhs.category() + || (__lhs.category() == __rhs.category() + && __lhs.value() < __rhs.value())); + } - template<typename charT, typename traits> - basic_ostream<charT,traits>& - operator<<(basic_ostream<charT, traits>& os, const error_code& __code); + template<typename _CharT, typename _Traits> + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) + { return (__os << __e.category().name() << ':' << __e.value()); } /// error_condition // Portable error identification struct error_condition { - error_condition() : _M_value(0), _M_cat(system_category) { } + error_condition() : _M_value(0), _M_cat(&posix_category) { } error_condition(int __v, const error_category& __cat) - : _M_value(__v), _M_cat(__cat) { } + : _M_value(__v), _M_cat(&__cat) { } - template<typename _ErrorEnum> - error_condition(typename enable_if< - is_error_condition_enum<_ErrorEnum>::value, - _ErrorEnum>::type __v) - : _M_value(__v), _M_cat(system_category) { } + template<typename _ErrorConditionEnum> + error_condition(_ErrorConditionEnum __e, + typename enable_if<is_error_condition_enum + <_ErrorConditionEnum>::value>::type* = 0) + : _M_value(__e), _M_cat(&posix_category) { } - void - assign(int val, const error_category& cat); + void + assign(int __v, const error_category& __cat) + { + _M_value = __v; + _M_cat = &__cat; + } - template<typename _ErrorEnum> - error_condition& - operator=(typename enable_if<is_error_condition_enum<_ErrorEnum>::value, - _ErrorEnum>::type __v) - { _M_value = __v; } + // DR 804. + template<typename _ErrorConditionEnum> + typename enable_if<is_error_condition_enum + <_ErrorConditionEnum>::value, error_condition&>::type + operator=(_ErrorConditionEnum __e) + { + _M_value = __e; + _M_cat = &posix_category; + return *this; + } void - clear(); + clear() + { + _M_value = 0; + _M_cat = &posix_category; + } // 19.4.3.4 observers int value() const { return _M_value; } - const error_category& - category() const { return _M_cat; } + const error_category& + category() const { return *_M_cat; } string message() const @@ -236,63 +260,75 @@ _GLIBCXX_BEGIN_NAMESPACE(std) operator __bool_type() const { return _M_value != 0 ? &__not_bool_type : false; } + // DR 804. private: int _M_value; - const error_category& _M_cat; + const error_category* _M_cat; }; - error_condition - make_error_condition(posix_error::posix_errno); - // 19.4.3.5 non-member functions inline bool - operator<(const error_condition& lhs, const error_condition& rhs) - { - bool __t1 = lhs.category() < rhs.category(); - bool __t2 = lhs.category() == rhs.category() && lhs.value() < rhs.value(); - return __t1 || __t2; + operator<(const error_condition& __lhs, const error_condition& __rhs) + { + return (__lhs.category() < __rhs.category() + || (__lhs.category() == __rhs.category() + && __lhs.value() < __rhs.value())); + } + + namespace posix_error + { + inline error_code + make_error_code(posix_errno __e) + { return error_code(__e, posix_category); } + + inline error_condition + make_error_condition(posix_errno __e) + { return error_condition(__e, posix_category); } } // 19.4.4 Comparison operators - inline bool - operator==(const error_code& lhs, const error_code& rhs) - { return lhs.category() == rhs.category() && lhs.value() == rhs.value(); } + inline bool + operator==(const error_code& __lhs, const error_code& __rhs) + { return (__lhs.category() == __rhs.category() + && __lhs.value() == __rhs.value()); } - inline bool - operator==(const error_code& lhs, const error_condition& rhs) + inline bool + operator==(const error_code& __lhs, const error_condition& __rhs) { - bool __t1 = lhs.category().equivalent(lhs.value(), rhs); - bool __t2 = rhs.category().equivalent(lhs, rhs.value()); - return __t1 || __t2; + return (__lhs.category().equivalent(__lhs.value(), __rhs) + || __rhs.category().equivalent(__lhs, __rhs.value())); } - inline bool - operator==(const error_condition& lhs, const error_code& rhs) + inline bool + operator==(const error_condition& __lhs, const error_code& __rhs) { - bool __t1 = rhs.category().equivalent(rhs.value(), lhs); - bool __t2 = lhs.category().equivalent(rhs, lhs.value()); - return __t1 || __t2; + return (__rhs.category().equivalent(__rhs.value(), __lhs) + || __lhs.category().equivalent(__rhs, __lhs.value())); } - inline bool - operator==(const error_condition& lhs, const error_condition& rhs) - { return lhs.category() == rhs.category() && lhs.value() == rhs.value(); } + inline bool + operator==(const error_condition& __lhs, const error_condition& __rhs) + { + return (__lhs.category() == __rhs.category() + && __lhs.value() == __rhs.value()); + } - inline bool - operator!=(const error_code& lhs, const error_code& rhs) - { return !(lhs == rhs); } + inline bool + operator!=(const error_code& __lhs, const error_code& __rhs) + { return !(__lhs == __rhs); } - inline bool - operator!=(const error_code& lhs, const error_condition& rhs) - { return !(lhs == rhs); } + inline bool + operator!=(const error_code& __lhs, const error_condition& __rhs) + { return !(__lhs == __rhs); } - inline bool - operator!=(const error_condition& lhs, const error_code& rhs) - { return !(lhs == rhs); } + inline bool + operator!=(const error_condition& __lhs, const error_code& __rhs) + { return !(__lhs == __rhs); } + + inline bool + operator!=(const error_condition& __lhs, const error_condition& __rhs) + { return !(__lhs == __rhs); } - inline bool - operator!=(const error_condition& lhs, const error_condition& rhs) - { return !(lhs == rhs); } /// Thrown to indicate error code of underlying system. class system_error : public std::runtime_error diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc index b7635fee4c00..e73884cc35fb 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc @@ -34,6 +34,6 @@ int main() } // { dg-error "is private" "" { target *-*-* } 105 } -// { dg-error "within this context" "" { target *-*-* } 41 } +// { dg-error "within this context" "" { target *-*-* } 40 } // { dg-error "first required here" "" { target *-*-* } 31 } // { dg-excess-errors "copy constructor" } diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc index 8ba68d645e19..9dc11b70a08d 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc @@ -40,7 +40,7 @@ int main() // 3 std::error_code e3(std::posix_error::operation_not_supported); VERIFY( e3.value() == int(std::posix_error::operation_not_supported) ); - VERIFY( e3.category() == std::system_category ); + VERIFY( e3.category() == std::posix_category ); return 0; } diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc new file mode 100644 index 000000000000..572d24495467 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 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. + +#include <system_error> +#include <testsuite_error.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + // 1 + std::error_condition e1; + VERIFY( e1.value() == 0 ); + VERIFY( e1.category() == std::posix_category ); + + // 2 + const __gnu_test::test_category cat; + std::error_condition e2(e1.value(), cat); + VERIFY( e2.value() == e1.value() ); + VERIFY( e2.category() == cat ); + + // 3 + std::error_condition e3(std::posix_error::operation_not_supported); + VERIFY( e3.value() == int(std::posix_error::operation_not_supported) ); + VERIFY( e3.category() == std::posix_category ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc new file mode 100644 index 000000000000..c1cda2626d4a --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 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. + +#include <system_error> +#include <testsuite_hooks.h> + +// unspecified bool operator positive tests +void test01() +{ + bool test __attribute__((unused)) = true; + + // 1 + std::error_condition e1; + if (e1) + { + VERIFY( false ); + } + + // 2 + std::error_condition e2(std::posix_error::operation_not_supported); + if (e2) + { + VERIFY( true ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc new file mode 100644 index 000000000000..cad5f4194803 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool_neg.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008 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 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. + +#include <system_error> +#include <testsuite_hooks.h> + +int test01() +{ + std::error_condition e; + int i = e; + + return i; +} + +// { dg-error "invalid conversion" "" { target *-*-* } 28 } diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc new file mode 100644 index 000000000000..4bdf36190a94 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 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. + +#include <system_error> +#include <testsuite_error.h> + +// unspecified bool operator positive tests +void test01() +{ + bool test __attribute__((unused)) = true; + + std::error_condition e1; + std::error_condition e2(std::posix_error::operation_not_supported); + + VERIFY( e1 == e1 ); + VERIFY( !(e1 == e2) ); + + const __gnu_test::test_category cat; + std::error_condition e3(e2.value(), cat); + VERIFY( !(e2 == e3) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc new file mode 100644 index 000000000000..1b78b0af029f --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 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. + +#include <system_error> +#include <testsuite_error.h> + +// unspecified bool operator positive tests +void test01() +{ + bool test __attribute__((unused)) = true; + + std::error_condition e1; + std::error_condition e2(std::posix_error::operation_not_supported); + + VERIFY( !(e1 != e1) ); + VERIFY( e1 != e2 ); + + const __gnu_test::test_category cat; + std::error_condition e3(e2.value(), cat); + VERIFY( e2 != e3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc b/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc index 96ab25e99991..2a3aa17c5e8e 100644 --- a/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc +++ b/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc @@ -51,9 +51,10 @@ void test01() { l.lock(); } - catch (std::system_error const& ex) + catch (const std::system_error& ex) { - VERIFY( ex.code() == std::posix_error::operation_not_permitted ); + VERIFY( ex.code() == std::error_code( + std::posix_error::operation_not_permitted) ); } catch (...) { @@ -89,7 +90,8 @@ void test02() } catch (const std::system_error& ex) { - VERIFY( ex.code() == std::posix_error::resource_deadlock_would_occur ); + VERIFY( ex.code() == std::error_code( + std::posix_error::resource_deadlock_would_occur) ); } catch (...) { diff --git a/libstdc++-v3/testsuite/util/testsuite_error.h b/libstdc++-v3/testsuite/util/testsuite_error.h index 56d641874b14..31f52e6e1f83 100644 --- a/libstdc++-v3/testsuite/util/testsuite_error.h +++ b/libstdc++-v3/testsuite/util/testsuite_error.h @@ -28,6 +28,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +#include <string> #include <testsuite_hooks.h> #ifndef _TESTSUITE_ERROR_H @@ -35,8 +36,6 @@ namespace __gnu_test { - using std::string; - struct test_category : public std::error_category { virtual const char* @@ -46,10 +45,9 @@ namespace __gnu_test return s; } - virtual string + virtual std::string message(int) const - { return string("message to be determined"); } - + { return std::string("message to be determined"); } }; struct test_derived_category : public test_category diff --git a/libstdc++-v3/testsuite/util/testsuite_hooks.cc b/libstdc++-v3/testsuite/util/testsuite_hooks.cc index 35ac5b2836fd..c64dc1b8067e 100644 --- a/libstdc++-v3/testsuite/util/testsuite_hooks.cc +++ b/libstdc++-v3/testsuite/util/testsuite_hooks.cc @@ -2,7 +2,7 @@ // Utility subroutines for the C++ library testsuite. // -// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -283,6 +283,7 @@ namespace __gnu_test { #ifdef _GLIBCXX_SYSV_SEM union semun val; + val.val = 0; // Avoid uninitialized variable warning. // Destroy the semaphore set only in the process that created it. if (pid_ == getpid()) semctl(sem_set_, 0, IPC_RMID, val); -- GitLab