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
This commit is contained in:
parent
b8a19ec486
commit
92010a793b
@ -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<>
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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)) { }
|
||||
|
@ -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)
|
||||
|
@ -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"; }
|
||||
|
||||
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 generic_error_category generic_category_instance;
|
||||
const system_error_category system_category_instance;
|
||||
}
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
const error_category&
|
||||
get_posix_category() { return gnu_category; }
|
||||
|
||||
const error_category&
|
||||
get_system_category() { return gnu_category; }
|
||||
|
||||
const error_category& system_category = system_category_instance;
|
||||
const error_category& generic_category = generic_category_instance;
|
||||
|
||||
system_error::~system_error() throw() { }
|
||||
|
||||
error_condition
|
||||
|
@ -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" }
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 );
|
||||
|
@ -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) );
|
||||
|
@ -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 );
|
||||
|
@ -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()
|
||||
|
@ -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 );
|
||||
|
@ -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) );
|
||||
|
@ -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 );
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
{
|
||||
|
@ -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 (...)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user