diff options
author | Chris Fairles <cfairles@gcc.gnu.org> | 2008-10-22 15:27:44 +0000 |
---|---|---|
committer | Chris Fairles <cfairles@gcc.gnu.org> | 2008-10-22 15:27:44 +0000 |
commit | 92010a793b9bc51b3312d9e07f3e83dc86ed1ddc (patch) | |
tree | 1982e8d2183d71a4fdf9f068b3bdf561915edb14 /libstdc++-v3 | |
parent | b8a19ec4860dcd9c9dba47902b414706479fa4f7 (diff) | |
download | gcc-92010a793b9bc51b3312d9e07f3e83dc86ed1ddc.zip gcc-92010a793b9bc51b3312d9e07f3e83dc86ed1ddc.tar.gz gcc-92010a793b9bc51b3312d9e07f3e83dc86ed1ddc.tar.bz2 |
system_error (is_error_code_enum): Specialize for errc.
2008-10-22 Chris Fairles <cfairles@gcc.gnu.org>
* include/std/system_error (is_error_code_enum): Specialize for errc.
(error_category::error_category): Defaulted and protected.
(error_category::~error_category): New, virtual.
(error_category::error_category(const error_category&),
error_category::operator=(const error_category&)): Deleted.
(get_system_category, get_posix_category): Remove (DR 890).
(system_category): External linkage (DR 890).
(posix_category): Remove.
(generic_category): Add. External linkage (DR 890).
(error_code::error_code<>(_ErrorCodeEnum)): Use generic_category.
(error_code::clear, error_code::operator=<>(_ErrorCodeEnum)): Forward to
error_code::assign, use generic_category.
(error_condition::error_condition,
error_condition::error_condition<>(_ErrorConditionEnum)): Use
generic_category.
(error_condition::clear,
error_condition::operator=<>(_ErrorConditionEnum)): Forward to
error_code::assign, use generic_category.
(make_error_code, make_error_condition): Define in namespace std.
* include/std/mutex (unique_lock<>::lock, unique_lock<>::try_lock,
unique_lock<>::try_lock_until<>(duration),
unique_lock<>::try_lock_for<>(duration)): Replace posix_error with errc.
* src/system_error.cc (system_error_category, generic_error_category):
New.
(gnu_error_category): Remove.
(get_system_category, get_posix_category): Remove (DR 890).
(system_category, generic_category): Define.
* src/functexcept.cc (__throw_system_error): Use generic_category.
* config/abi/pre/gnu.ver: Export system_category and generic_category,
remove get_system_category and get_generic_category (DR 890).
* config/os/generic/error_constants.h (posix_errno): Rename to errc, use
enum class type. Fix spelling.
* config/os/mingw32/error_constants.h (posix_errno): Likewise.
* testsuite/19_diagnostics/error_code/cons/1.cc: Use errc and
generic_category.
* testsuite/19_diagnostics/error_code/operators/bool.cc: Use errc.
* testsuite/19_diagnostics/error_code/operators/equal.cc: Likewise.
* testsuite/19_diagnostics/error_code/operators/not_equal.cc: Likewise.
* testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Update
dg-error line numbers.
* testsuite/19_diagnostics/error_condition/cons/1.cc: Use
generic_category.
* testsuite/19_diagnostics/error_condition/operators/bool.cc: Use errc.
* testsuite/19_diagnostics/error_condition/operators/equal.cc: Likewise.
* testsuite/19_diagnostics/error_condition/operators/not_equal.cc:
Likewise.
* testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: New.
* testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc:
Remove using tests since errc is not a namespace.
* testsuite/19_diagnostics/system_error/cons-1.cc: Use errc.
* testsuite/19_diagnostics/system_error/what-4.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc:
Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc:
Likewise.
* testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
From-SVN: r141297
Diffstat (limited to 'libstdc++-v3')
24 files changed, 319 insertions, 230 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4531127..256aa5b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,62 @@ +2008-10-22 Chris Fairles <cfairles@gcc.gnu.org> + + * include/std/system_error (is_error_code_enum): Specialize for errc. + (error_category::error_category): Defaulted and protected. + (error_category::~error_category): New, virtual. + (error_category::error_category(const error_category&), + error_category::operator=(const error_category&)): Deleted. + (get_system_category, get_posix_category): Remove (DR 890). + (system_category): External linkage (DR 890). + (posix_category): Remove. + (generic_category): Add. External linkage (DR 890). + (error_code::error_code<>(_ErrorCodeEnum)): Use generic_category. + (error_code::clear, error_code::operator=<>(_ErrorCodeEnum)): Forward to + error_code::assign, use generic_category. + (error_condition::error_condition, + error_condition::error_condition<>(_ErrorConditionEnum)): Use + generic_category. + (error_condition::clear, + error_condition::operator=<>(_ErrorConditionEnum)): Forward to + error_code::assign, use generic_category. + (make_error_code, make_error_condition): Define in namespace std. + * include/std/mutex (unique_lock<>::lock, unique_lock<>::try_lock, + unique_lock<>::try_lock_until<>(duration), + unique_lock<>::try_lock_for<>(duration)): Replace posix_error with errc. + * src/system_error.cc (system_error_category, generic_error_category): + New. + (gnu_error_category): Remove. + (get_system_category, get_posix_category): Remove (DR 890). + (system_category, generic_category): Define. + * src/functexcept.cc (__throw_system_error): Use generic_category. + * config/abi/pre/gnu.ver: Export system_category and generic_category, + remove get_system_category and get_generic_category (DR 890). + * config/os/generic/error_constants.h (posix_errno): Rename to errc, use + enum class type. Fix spelling. + * config/os/mingw32/error_constants.h (posix_errno): Likewise. + * testsuite/19_diagnostics/error_code/cons/1.cc: Use errc and + generic_category. + * testsuite/19_diagnostics/error_code/operators/bool.cc: Use errc. + * testsuite/19_diagnostics/error_code/operators/equal.cc: Likewise. + * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Likewise. + * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Update + dg-error line numbers. + * testsuite/19_diagnostics/error_condition/cons/1.cc: Use + generic_category. + * testsuite/19_diagnostics/error_condition/operators/bool.cc: Use errc. + * testsuite/19_diagnostics/error_condition/operators/equal.cc: Likewise. + * testsuite/19_diagnostics/error_condition/operators/not_equal.cc: + Likewise. + * testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc: New. + * testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc: + Remove using tests since errc is not a namespace. + * testsuite/19_diagnostics/system_error/cons-1.cc: Use errc. + * testsuite/19_diagnostics/system_error/what-4.cc: Likewise. + * testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc: + Likewise. + * testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc: + Likewise. + * testsuite/30_threads/unique_lock/locking/2.cc: Likewise. + 2008-10-20 Paolo Carlini <paolo.carlini@oracle.com> * include/tr1_impl/hashtable_policy.h (_Hash_node<>::_Hash_node<> diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 024fcfd..04262ba 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -922,8 +922,8 @@ GLIBCXX_3.4.11 { _ZNSt6threadD2Ev; # system_error - _ZSt18get_posix_categoryv; - _ZSt19get_system_categoryv; + _ZSt15system_category; + _ZSt16generic_category; _ZNKSt10error_code23default_error_conditionEv; _ZNKSt14error_category23default_error_conditionEi; diff --git a/libstdc++-v3/config/os/generic/error_constants.h b/libstdc++-v3/config/os/generic/error_constants.h index 644d111..2304a4c 100644 --- a/libstdc++-v3/config/os/generic/error_constants.h +++ b/libstdc++-v3/config/os/generic/error_constants.h @@ -40,9 +40,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) -namespace posix_error -{ - enum posix_errno + enum class errc { address_family_not_supported = EAFNOSUPPORT, address_in_use = EADDRINUSE, @@ -168,7 +166,7 @@ namespace posix_error too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, - too_many_synbolic_link_levels = ELOOP, + too_many_symbolic_link_levels = ELOOP, #ifdef _GLIBCXX_HAVE_EOVERFLOW value_too_large = EOVERFLOW, @@ -177,7 +175,6 @@ namespace posix_error wrong_protocol_type = EPROTOTYPE, no_posix_equivalent = 1L << 16 }; -} _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h b/libstdc++-v3/config/os/mingw32/error_constants.h index 27af222..00e6392 100644 --- a/libstdc++-v3/config/os/mingw32/error_constants.h +++ b/libstdc++-v3/config/os/mingw32/error_constants.h @@ -41,10 +41,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std) -namespace posix_error { // Most of the commented-out error codes are socket-related and could be // replaced by Winsock WSA-prefixed equivalents. - enum posix_errno + enum class errc { // address_family_not_supported = EAFNOSUPPORT, // address_in_use = EADDRINUSE, @@ -121,12 +120,11 @@ namespace posix_error { too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, - // too_many_synbolic_link_levels = ELOOP, + // too_many_symbolic_link_levels = ELOOP, // value_too_large = EOVERFLOW, // wrong_protocol_type = EPROTOTYPE, no_posix_equivalent = 1L << 16 }; -} _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index f3848d0..e392236 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -489,9 +489,9 @@ namespace std lock() { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_device->lock(); @@ -503,9 +503,9 @@ namespace std try_lock() { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_owns = _M_device->try_lock(); @@ -518,9 +518,9 @@ namespace std try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime) { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_owns = _M_device->try_lock_until(__atime); @@ -533,9 +533,9 @@ namespace std try_lock_for(const chrono::duration<_Rep, _Period>& __rtime) { if (!_M_device) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_owns) - __throw_system_error(posix_error::resource_deadlock_would_occur); + __throw_system_error((int)errc::resource_deadlock_would_occur); else { _M_owns = _M_device->try_lock_for(__rtime); @@ -547,7 +547,7 @@ namespace std unlock() { if (!_M_owns) - __throw_system_error(posix_error::operation_not_permitted); + __throw_system_error((int)errc::operation_not_permitted); else if (_M_device) { _M_device->unlock(); diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 6a09ebf..4a93e5f 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -57,7 +57,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) struct is_error_code_enum : public false_type { }; template<> - struct is_error_code_enum<posix_error::posix_errno> + struct is_error_code_enum<errc> : public true_type { }; /// is_error_condition_enum @@ -65,14 +65,21 @@ _GLIBCXX_BEGIN_NAMESPACE(std) struct is_error_condition_enum : public false_type { }; template<> - struct is_error_condition_enum<posix_error::posix_errno> + struct is_error_condition_enum<errc> : public true_type { }; /// error_category - struct error_category + class error_category { - error_category() { } + protected: + error_category() = default; + + public: + virtual ~error_category() { } + + error_category(const error_category&) = delete; + error_category& operator=(const error_category&) = delete; virtual const char* name() const = 0; @@ -100,19 +107,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) bool operator!=(const error_category& __other) const { return this != &__other; } - - private: - error_category(const error_category&); - - error_category& - operator=(const error_category&); }; - 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(); + // DR 890. + extern const error_category& system_category; + extern const error_category& generic_category; /// error_code // Implementation-specific error identification @@ -127,7 +126,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(&posix_category) + : _M_value(static_cast<int>(__e)), _M_cat(&generic_category) { } void @@ -139,10 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void clear() - { - _M_value = 0; - _M_cat = &system_category; - } + { assign(0, system_category); } // DR 804. template<typename _ErrorCodeEnum> @@ -150,8 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) error_code&>::type operator=(_ErrorCodeEnum __e) { - _M_value = __e; - _M_cat = &posix_category; + assign(static_cast<int>(__e), generic_category); return *this; } @@ -184,7 +179,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const error_category* _M_cat; }; - // 19.4.2.5 non-member functions + // 19.4.2.6 non-member functions + inline error_code + make_error_code(errc __e) + { return error_code(static_cast<int>(__e), generic_category); } + inline bool operator<(const error_code& __lhs, const error_code& __rhs) { @@ -203,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // Portable error identification struct error_condition { - error_condition() : _M_value(0), _M_cat(&posix_category) { } + error_condition() : _M_value(0), _M_cat(&generic_category) { } error_condition(int __v, const error_category& __cat) : _M_value(__v), _M_cat(&__cat) { } @@ -212,7 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) error_condition(_ErrorConditionEnum __e, typename enable_if<is_error_condition_enum <_ErrorConditionEnum>::value>::type* = 0) - : _M_value(__e), _M_cat(&posix_category) { } + : _M_value(static_cast<int>(__e)), _M_cat(&generic_category) { } void assign(int __v, const error_category& __cat) @@ -227,17 +226,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std) <_ErrorConditionEnum>::value, error_condition&>::type operator=(_ErrorConditionEnum __e) { - _M_value = __e; - _M_cat = &posix_category; + assign(static_cast<int>(__e), generic_category); return *this; } void clear() - { - _M_value = 0; - _M_cat = &posix_category; - } + { assign(0, generic_category); } // 19.4.3.4 observers int @@ -266,7 +261,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const error_category* _M_cat; }; - // 19.4.3.5 non-member functions + // 19.4.3.6 non-member functions + inline error_condition + make_error_condition(errc __e) + { return error_condition(static_cast<int>(__e), generic_category); } + inline bool operator<(const error_condition& __lhs, const error_condition& __rhs) { @@ -275,17 +274,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) && __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) @@ -342,6 +330,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) system_error(error_code __ec, const string& __what) : runtime_error(__what), _M_code(__ec) { } + + /* + * TODO: Add const char* ctors to all exceptions. + * + * system_error(error_code __ec, const char* __what) + * : runtime_error(__what), _M_code(__ec) { } + * + * system_error(int __v, const error_category& __ecat, const char* __what) + * : runtime_error(__what), _M_code(error_code(__v, __ecat)) { } + */ system_error(int __v, const error_category& __ecat) : runtime_error(""), _M_code(error_code(__v, __ecat)) { } diff --git a/libstdc++-v3/src/functexcept.cc b/libstdc++-v3/src/functexcept.cc index 95b65bb..266e035 100644 --- a/libstdc++-v3/src/functexcept.cc +++ b/libstdc++-v3/src/functexcept.cc @@ -102,7 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) void __throw_system_error(int __i) - { throw system_error(error_code(__i, system_category)); } + { throw system_error(error_code(__i, generic_category)); } void __throw_ios_failure(const char* __s) diff --git a/libstdc++-v3/src/system_error.cc b/libstdc++-v3/src/system_error.cc index 6724ef7..dd950eb 100644 --- a/libstdc++-v3/src/system_error.cc +++ b/libstdc++-v3/src/system_error.cc @@ -36,15 +36,12 @@ namespace { using std::string; - - struct gnu_error_category : public std::error_category + + struct generic_error_category : public std::error_category { virtual const char* name() const - { - const char* s = "GNU"; - return s; - } + { return "generic"; } virtual string message(int i) const @@ -55,17 +52,30 @@ namespace } }; - const gnu_error_category gnu_category; -} + struct system_error_category : public std::error_category + { + virtual const char* + name() const + { return "system"; } -_GLIBCXX_BEGIN_NAMESPACE(std) + virtual string + message(int i) const + { + // XXX locale issues: how does one get or set loc. + // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc) + return string(strerror(i)); + } + }; - const error_category& - get_posix_category() { return gnu_category; } + const generic_error_category generic_category_instance; + const system_error_category system_category_instance; +} - const error_category& - get_system_category() { return gnu_category; } +_GLIBCXX_BEGIN_NAMESPACE(std) + const error_category& system_category = system_category_instance; + const error_category& generic_category = generic_category_instance; + system_error::~system_error() throw() { } error_condition 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 e73884c..8adf3fe 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 @@ -33,7 +33,7 @@ int main() return 0; } -// { dg-error "is private" "" { target *-*-* } 105 } -// { dg-error "within this context" "" { target *-*-* } 40 } +// { dg-error "deleted function" "" { target *-*-* } 81 } +// { dg-error "used here" "" { 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 9dc11b7..742eb40 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc @@ -38,9 +38,9 @@ int main() VERIFY( e2.category() == cat ); // 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::posix_category ); + std::error_code e3(std::errc::operation_not_supported); + VERIFY( e3.value() == int(std::errc::operation_not_supported) ); + VERIFY( e3.category() == std::generic_category ); return 0; } diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc index 04fd44f..385960c 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc @@ -35,7 +35,7 @@ int main() } // 2 - std::error_code e2(std::posix_error::operation_not_supported); + std::error_code e2(std::errc::operation_not_supported); if (e2) { VERIFY( true ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc index a8fc65c..8fcf1e5 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc @@ -28,7 +28,7 @@ int main() bool test __attribute__((unused)) = true; std::error_code e1; - std::error_code e2(std::posix_error::operation_not_supported); + std::error_code e2(std::errc::operation_not_supported); VERIFY( e1 == e1 ); VERIFY( !(e1 == e2) ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc index d5d7555..aca79ad 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc @@ -28,7 +28,7 @@ int main() bool test __attribute__((unused)) = true; std::error_code e1; - std::error_code e2(std::posix_error::operation_not_supported); + std::error_code e2(std::errc::operation_not_supported); VERIFY( !(e1 != e1) ); VERIFY( e1 != e2 ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc index 572d244..5ea76f7 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc @@ -28,7 +28,7 @@ void test01() // 1 std::error_condition e1; VERIFY( e1.value() == 0 ); - VERIFY( e1.category() == std::posix_category ); + VERIFY( e1.category() == std::generic_category ); // 2 const __gnu_test::test_category cat; @@ -37,9 +37,9 @@ void test01() 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 ); + std::error_condition e3(std::errc::operation_not_supported); + VERIFY( e3.value() == int(std::errc::operation_not_supported) ); + VERIFY( e3.category() == std::generic_category ); } int main() diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc index c1cda26..d55256d 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc @@ -34,7 +34,7 @@ void test01() } // 2 - std::error_condition e2(std::posix_error::operation_not_supported); + std::error_condition e2(std::errc::operation_not_supported); if (e2) { VERIFY( true ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc index 4bdf361..7d7c80f 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc @@ -27,7 +27,7 @@ void test01() bool test __attribute__((unused)) = true; std::error_condition e1; - std::error_condition e2(std::posix_error::operation_not_supported); + std::error_condition e2(std::errc::operation_not_supported); VERIFY( e1 == e1 ); VERIFY( !(e1 == e2) ); 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 index 1b78b0a..50a4e90 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc @@ -27,7 +27,7 @@ void test01() bool test __attribute__((unused)) = true; std::error_condition e1; - std::error_condition e2(std::posix_error::operation_not_supported); + std::error_condition e2(std::errc::operation_not_supported); VERIFY( !(e1 != e1) ); VERIFY( e1 != e2 ); diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc new file mode 100644 index 0000000..d2325d1 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc @@ -0,0 +1,159 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007 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> + +#define TEST_ERRC(x) errc x(errc::x); (void)x + +void test01() +{ + using std::errc; + + TEST_ERRC(address_family_not_supported); + TEST_ERRC(address_in_use); + TEST_ERRC(address_not_available); + TEST_ERRC(already_connected); + TEST_ERRC(argument_list_too_long); + TEST_ERRC(argument_out_of_domain); + TEST_ERRC(bad_address); + TEST_ERRC(bad_file_descriptor); + +#ifdef _GLIBCXX_HAVE_EBADMSG + TEST_ERRC(bad_message); +#endif + + TEST_ERRC(broken_pipe); + TEST_ERRC(connection_aborted); + TEST_ERRC(connection_already_in_progress); + TEST_ERRC(connection_refused); + TEST_ERRC(connection_reset); + TEST_ERRC(cross_device_link); + TEST_ERRC(destination_address_required); + TEST_ERRC(device_or_resource_busy); + TEST_ERRC(directory_not_empty); + TEST_ERRC(executable_format_error); + TEST_ERRC(file_exists); + TEST_ERRC(file_too_large); + TEST_ERRC(filename_too_long); + TEST_ERRC(function_not_supported); + TEST_ERRC(host_unreachable); + +#ifdef _GLIBCXX_HAVE_EIDRM + TEST_ERRC(identifier_removed); +#endif + + TEST_ERRC(illegal_byte_sequence); + TEST_ERRC(inappropriate_io_control_operation); + TEST_ERRC(interrupted); + TEST_ERRC(invalid_argument); + TEST_ERRC(invalid_seek); + TEST_ERRC(io_error); + TEST_ERRC(is_a_directory); + TEST_ERRC(message_size); + TEST_ERRC(network_down); + TEST_ERRC(network_reset); + TEST_ERRC(network_unreachable); + TEST_ERRC(no_buffer_space); + TEST_ERRC(no_child_process); + +#ifdef _GLIBCXX_HAVE_ENOLINK + TEST_ERRC(no_link); +#endif + + TEST_ERRC(no_lock_available); + +#ifdef _GLIBCXX_HAVE_ENODATA + TEST_ERRC(no_message_available); +#endif + + TEST_ERRC(no_message); + TEST_ERRC(no_posix_equivalent); + TEST_ERRC(no_protocol_option); + TEST_ERRC(no_space_on_device); + +#ifdef _GLIBCXX_HAVE_ENOSR + TEST_ERRC(no_stream_resources); +#endif + + TEST_ERRC(no_such_device_or_address); + TEST_ERRC(no_such_device); + TEST_ERRC(no_such_file_or_directory); + TEST_ERRC(no_such_process); + TEST_ERRC(not_a_directory); + TEST_ERRC(not_a_socket); + +#ifdef _GLIBCXX_HAVE_ENOSTR + TEST_ERRC(not_a_stream); +#endif + + TEST_ERRC(not_connected); + TEST_ERRC(not_enough_memory); + TEST_ERRC(not_supported); + +#ifdef _GLIBCXX_HAVE_ECANCELED + TEST_ERRC(operation_canceled); +#endif + + TEST_ERRC(operation_in_progress); + TEST_ERRC(operation_not_permitted); + TEST_ERRC(operation_not_supported); + TEST_ERRC(operation_would_block); + +#ifdef _GLIBCXX_HAVE_EOWNERDEAD + TEST_ERRC(owner_dead); +#endif + + TEST_ERRC(permission_denied); + +#ifdef _GLIBCXX_HAVE_EPROTO + TEST_ERRC(protocol_error); +#endif + + TEST_ERRC(protocol_not_supported); + TEST_ERRC(read_only_file_system); + TEST_ERRC(resource_deadlock_would_occur); + TEST_ERRC(resource_unavailable_try_again); + TEST_ERRC(result_out_of_range); + +#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE + TEST_ERRC(state_not_recoverable); +#endif + +#ifdef _GLIBCXX_HAVE_ETIME + TEST_ERRC(stream_timeout); +#endif + +#ifdef _GLIBCXX_HAVE_ETXTBSY + TEST_ERRC(text_file_busy); +#endif + + TEST_ERRC(timed_out); + TEST_ERRC(too_many_files_open_in_system); + TEST_ERRC(too_many_files_open); + TEST_ERRC(too_many_links); + TEST_ERRC(too_many_symbolic_link_levels); + +#ifdef _GLIBCXX_HAVE_EOVERFLOW + TEST_ERRC(value_too_large); +#endif + + TEST_ERRC(wrong_protocol_type); +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc index 00a2457..416d849 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc @@ -27,135 +27,4 @@ namespace gnu using std::error_code; using std::error_category; using std::system_category; - - using std::posix_error::posix_errno; - using std::posix_error::address_family_not_supported; - using std::posix_error::address_in_use; - using std::posix_error::address_not_available; - using std::posix_error::already_connected; - using std::posix_error::argument_list_too_long; - using std::posix_error::argument_out_of_domain; - using std::posix_error::bad_address; - using std::posix_error::bad_file_descriptor; - -#ifdef _GLIBCXX_HAVE_EBADMSG - using std::posix_error::bad_message; -#endif - - using std::posix_error::broken_pipe; - using std::posix_error::connection_aborted; - using std::posix_error::connection_already_in_progress; - using std::posix_error::connection_refused; - using std::posix_error::connection_reset; - using std::posix_error::cross_device_link; - using std::posix_error::destination_address_required; - using std::posix_error::device_or_resource_busy; - using std::posix_error::directory_not_empty; - using std::posix_error::executable_format_error; - using std::posix_error::file_exists; - using std::posix_error::file_too_large; - using std::posix_error::filename_too_long; - using std::posix_error::function_not_supported; - using std::posix_error::host_unreachable; - -#ifdef _GLIBCXX_HAVE_EIDRM - using std::posix_error::identifier_removed; -#endif - - using std::posix_error::illegal_byte_sequence; - using std::posix_error::inappropriate_io_control_operation; - using std::posix_error::interrupted; - using std::posix_error::invalid_argument; - using std::posix_error::invalid_seek; - using std::posix_error::io_error; - using std::posix_error::is_a_directory; - using std::posix_error::message_size; - using std::posix_error::network_down; - using std::posix_error::network_reset; - using std::posix_error::network_unreachable; - using std::posix_error::no_buffer_space; - using std::posix_error::no_child_process; - -#ifdef _GLIBCXX_HAVE_ENOLINK - using std::posix_error::no_link; -#endif - - using std::posix_error::no_lock_available; - -#ifdef _GLIBCXX_HAVE_ENODATA - using std::posix_error::no_message_available; -#endif - - using std::posix_error::no_message; - using std::posix_error::no_posix_equivalent; - using std::posix_error::no_protocol_option; - using std::posix_error::no_space_on_device; - -#ifdef _GLIBCXX_HAVE_ENOSR - using std::posix_error::no_stream_resources; -#endif - - using std::posix_error::no_such_device_or_address; - using std::posix_error::no_such_device; - using std::posix_error::no_such_file_or_directory; - using std::posix_error::no_such_process; - using std::posix_error::not_a_directory; - using std::posix_error::not_a_socket; - -#ifdef _GLIBCXX_HAVE_ENOSTR - using std::posix_error::not_a_stream; -#endif - - using std::posix_error::not_connected; - using std::posix_error::not_enough_memory; - using std::posix_error::not_supported; - -#ifdef _GLIBCXX_HAVE_ECANCELED - using std::posix_error::operation_canceled; -#endif - - using std::posix_error::operation_in_progress; - using std::posix_error::operation_not_permitted; - using std::posix_error::operation_not_supported; - using std::posix_error::operation_would_block; - -#ifdef _GLIBCXX_HAVE_EOWNERDEAD - using std::posix_error::owner_dead; -#endif - - using std::posix_error::permission_denied; - -#ifdef _GLIBCXX_HAVE_EPROTO - using std::posix_error::protocol_error; -#endif - - using std::posix_error::protocol_not_supported; - using std::posix_error::read_only_file_system; - using std::posix_error::resource_deadlock_would_occur; - using std::posix_error::resource_unavailable_try_again; - using std::posix_error::result_out_of_range; - -#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE - using std::posix_error::state_not_recoverable; -#endif - -#ifdef _GLIBCXX_HAVE_ETIME - using std::posix_error::stream_timeout; -#endif - -#ifdef _GLIBCXX_HAVE_ETXTBSY - using std::posix_error::text_file_busy; -#endif - - using std::posix_error::timed_out; - using std::posix_error::too_many_files_open_in_system; - using std::posix_error::too_many_files_open; - using std::posix_error::too_many_links; - using std::posix_error::too_many_synbolic_link_levels; - -#ifdef _GLIBCXX_HAVE_EOVERFLOW - using std::posix_error::value_too_large; -#endif - - using std::posix_error::wrong_protocol_type; } diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc index 9fc24f1..bf73398 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc @@ -27,7 +27,7 @@ int main() { bool test __attribute__((unused)) = true; const std::string s("too late: boulangerie out of pain au raisin"); - const std::error_code e(std::posix_error::operation_not_supported); + const std::error_code e(std::errc::operation_not_supported); // 1 { diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc index 5934982..e7304a1 100644 --- a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc @@ -32,7 +32,7 @@ void test01() bool test __attribute__((unused)) = true; std::string s("after nine thirty, this request cannot be met"); - std::system_error obj = std::system_error(std::posix_error::invalid_argument, s); + std::system_error obj = std::system_error(std::errc::invalid_argument, s); std::string s1(obj.what()); std::string s2(obj.what()); VERIFY( s1 == s2 ); diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc index e4814d6..8203131 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc @@ -33,7 +33,7 @@ void test() char buf[64]; error_code e1; - error_code e2(posix_error::bad_address); + error_code e2(errc::bad_address); string s, s1, s2; { diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc index 73c838b..7cd4165 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc @@ -33,7 +33,7 @@ void test() wchar_t buf[64]; error_code e1; - error_code e2(posix_error::bad_address); + error_code e2(errc::bad_address); wstring s, s1, s2; { 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 2a3aa17..e2599eb 100644 --- a/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc +++ b/libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc @@ -53,8 +53,7 @@ void test01() } catch (const std::system_error& ex) { - VERIFY( ex.code() == std::error_code( - std::posix_error::operation_not_permitted) ); + VERIFY( ex.code() == std::error_code(std::errc::operation_not_permitted) ); } catch (...) { @@ -91,7 +90,7 @@ void test02() catch (const std::system_error& ex) { VERIFY( ex.code() == std::error_code( - std::posix_error::resource_deadlock_would_occur) ); + std::errc::resource_deadlock_would_occur) ); } catch (...) { |