Commit cd88bb8c by Paolo Carlini Committed by Paolo Carlini

system_error: Use noexcept.

2011-07-20  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/std/system_error: Use noexcept.
	* src/system_error.cc: Likewise.
	* testsuite/19_diagnostics/error_condition/modifiers/39881.cc: Adjust.
	* testsuite/19_diagnostics/error_condition/cons/39881.cc: Likewise.
	* testsuite/19_diagnostics/error_code/modifiers/39882.cc: Likewise.
	* testsuite/19_diagnostics/error_code/cons/39882.cc: Likewise.
	* testsuite/util/testsuite_error.h: Likewise.

	* include/std/system_error (error_code::error_code(_ErrorCodeEnum)):
	Use enable_if on template parameter default.
	(error_condition::error_condition(_ErrorConditionEnum)): Likewise.

From-SVN: r176529
parent d05f3564
2011-07-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/system_error: Use noexcept.
* src/system_error.cc: Likewise.
* testsuite/19_diagnostics/error_condition/modifiers/39881.cc: Adjust.
* testsuite/19_diagnostics/error_condition/cons/39881.cc: Likewise.
* testsuite/19_diagnostics/error_code/modifiers/39882.cc: Likewise.
* testsuite/19_diagnostics/error_code/cons/39882.cc: Likewise.
* testsuite/util/testsuite_error.h: Likewise.
* include/std/system_error (error_code::error_code(_ErrorCodeEnum)):
Use enable_if on template parameter default.
(error_condition::error_condition(_ErrorConditionEnum)): Likewise.
2011-07-20 Ed Smith-Rowland <3dw4rd@verizon.net> 2011-07-20 Ed Smith-Rowland <3dw4rd@verizon.net>
* include/precompiled/stdc++.h: Add scoped_allocator. * include/precompiled/stdc++.h: Add scoped_allocator.
......
...@@ -66,47 +66,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -66,47 +66,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class error_category class error_category
{ {
protected: protected:
error_category(); error_category() noexcept;
public: public:
virtual ~error_category(); virtual ~error_category() noexcept;
error_category(const error_category&) = delete; error_category(const error_category&) = delete;
error_category& operator=(const error_category&) = delete; error_category& operator=(const error_category&) = delete;
virtual const char* virtual const char*
name() const = 0; name() const noexcept = 0;
virtual string virtual string
message(int) const = 0; message(int) const = 0;
virtual error_condition virtual error_condition
default_error_condition(int __i) const; default_error_condition(int __i) const noexcept;
virtual bool virtual bool
equivalent(int __i, const error_condition& __cond) const; equivalent(int __i, const error_condition& __cond) const noexcept;
virtual bool virtual bool
equivalent(const error_code& __code, int __i) const; equivalent(const error_code& __code, int __i) const noexcept;
bool bool
operator<(const error_category& __other) const operator<(const error_category& __other) const noexcept
{ return less<const error_category*>()(this, &__other); } { return less<const error_category*>()(this, &__other); }
bool bool
operator==(const error_category& __other) const operator==(const error_category& __other) const noexcept
{ return this == &__other; } { return this == &__other; }
bool bool
operator!=(const error_category& __other) const operator!=(const error_category& __other) const noexcept
{ return this != &__other; } { return this != &__other; }
}; };
// DR 890. // DR 890.
_GLIBCXX_CONST const error_category& system_category() throw(); _GLIBCXX_CONST const error_category& system_category() noexcept;
_GLIBCXX_CONST const error_category& generic_category() throw(); _GLIBCXX_CONST const error_category& generic_category() noexcept;
error_code make_error_code(errc); error_code make_error_code(errc) noexcept;
template<typename _Tp> template<typename _Tp>
struct hash; struct hash;
...@@ -115,49 +115,49 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -115,49 +115,49 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Implementation-specific error identification // Implementation-specific error identification
struct error_code struct error_code
{ {
error_code() error_code() noexcept
: _M_value(0), _M_cat(&system_category()) { } : _M_value(0), _M_cat(&system_category()) { }
error_code(int __v, const error_category& __cat) error_code(int __v, const error_category& __cat) noexcept
: _M_value(__v), _M_cat(&__cat) { } : _M_value(__v), _M_cat(&__cat) { }
template<typename _ErrorCodeEnum> template<typename _ErrorCodeEnum, typename = typename
error_code(_ErrorCodeEnum __e, enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type>
typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0) error_code(_ErrorCodeEnum __e) noexcept
{ *this = make_error_code(__e); } { *this = make_error_code(__e); }
void void
assign(int __v, const error_category& __cat) assign(int __v, const error_category& __cat) noexcept
{ {
_M_value = __v; _M_value = __v;
_M_cat = &__cat; _M_cat = &__cat;
} }
void void
clear() clear() noexcept
{ assign(0, system_category()); } { assign(0, system_category()); }
// DR 804. // DR 804.
template<typename _ErrorCodeEnum> template<typename _ErrorCodeEnum>
typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value, typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value,
error_code&>::type error_code&>::type
operator=(_ErrorCodeEnum __e) operator=(_ErrorCodeEnum __e) noexcept
{ return *this = make_error_code(__e); } { return *this = make_error_code(__e); }
int int
value() const { return _M_value; } value() const noexcept { return _M_value; }
const error_category& const error_category&
category() const { return *_M_cat; } category() const noexcept { return *_M_cat; }
error_condition error_condition
default_error_condition() const; default_error_condition() const noexcept;
string string
message() const message() const
{ return category().message(value()); } { return category().message(value()); }
explicit operator bool() const explicit operator bool() const noexcept
{ return _M_value != 0 ? true : false; } { return _M_value != 0 ? true : false; }
// DR 804. // DR 804.
...@@ -170,11 +170,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -170,11 +170,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 19.4.2.6 non-member functions // 19.4.2.6 non-member functions
inline error_code inline error_code
make_error_code(errc __e) make_error_code(errc __e) noexcept
{ return error_code(static_cast<int>(__e), generic_category()); } { return error_code(static_cast<int>(__e), generic_category()); }
inline bool inline bool
operator<(const error_code& __lhs, const error_code& __rhs) operator<(const error_code& __lhs, const error_code& __rhs) noexcept
{ {
return (__lhs.category() < __rhs.category() return (__lhs.category() < __rhs.category()
|| (__lhs.category() == __rhs.category() || (__lhs.category() == __rhs.category()
...@@ -186,26 +186,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -186,26 +186,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
{ return (__os << __e.category().name() << ':' << __e.value()); } { return (__os << __e.category().name() << ':' << __e.value()); }
error_condition make_error_condition(errc); error_condition make_error_condition(errc) noexcept;
/// error_condition /// error_condition
// Portable error identification // Portable error identification
struct error_condition struct error_condition
{ {
error_condition() error_condition() noexcept
: _M_value(0), _M_cat(&generic_category()) { } : _M_value(0), _M_cat(&generic_category()) { }
error_condition(int __v, const error_category& __cat) error_condition(int __v, const error_category& __cat) noexcept
: _M_value(__v), _M_cat(&__cat) { } : _M_value(__v), _M_cat(&__cat) { }
template<typename _ErrorConditionEnum> template<typename _ErrorConditionEnum, typename = typename
error_condition(_ErrorConditionEnum __e, enable_if<is_error_condition_enum<_ErrorConditionEnum>::value>::type>
typename enable_if<is_error_condition_enum error_condition(_ErrorConditionEnum __e) noexcept
<_ErrorConditionEnum>::value>::type* = 0)
{ *this = make_error_condition(__e); } { *this = make_error_condition(__e); }
void void
assign(int __v, const error_category& __cat) assign(int __v, const error_category& __cat) noexcept
{ {
_M_value = __v; _M_value = __v;
_M_cat = &__cat; _M_cat = &__cat;
...@@ -215,25 +214,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -215,25 +214,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ErrorConditionEnum> template<typename _ErrorConditionEnum>
typename enable_if<is_error_condition_enum typename enable_if<is_error_condition_enum
<_ErrorConditionEnum>::value, error_condition&>::type <_ErrorConditionEnum>::value, error_condition&>::type
operator=(_ErrorConditionEnum __e) operator=(_ErrorConditionEnum __e) noexcept
{ return *this = make_error_condition(__e); } { return *this = make_error_condition(__e); }
void void
clear() clear() noexcept
{ assign(0, generic_category()); } { assign(0, generic_category()); }
// 19.4.3.4 observers // 19.4.3.4 observers
int int
value() const { return _M_value; } value() const noexcept { return _M_value; }
const error_category& const error_category&
category() const { return *_M_cat; } category() const noexcept { return *_M_cat; }
string string
message() const message() const
{ return category().message(value()); } { return category().message(value()); }
explicit operator bool() const explicit operator bool() const noexcept
{ return _M_value != 0 ? true : false; } { return _M_value != 0 ? true : false; }
// DR 804. // DR 804.
...@@ -244,11 +243,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -244,11 +243,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 19.4.3.6 non-member functions // 19.4.3.6 non-member functions
inline error_condition inline error_condition
make_error_condition(errc __e) make_error_condition(errc __e) noexcept
{ return error_condition(static_cast<int>(__e), generic_category()); } { return error_condition(static_cast<int>(__e), generic_category()); }
inline bool inline bool
operator<(const error_condition& __lhs, const error_condition& __rhs) operator<(const error_condition& __lhs,
const error_condition& __rhs) noexcept
{ {
return (__lhs.category() < __rhs.category() return (__lhs.category() < __rhs.category()
|| (__lhs.category() == __rhs.category() || (__lhs.category() == __rhs.category()
...@@ -257,45 +257,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -257,45 +257,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 19.4.4 Comparison operators // 19.4.4 Comparison operators
inline bool inline bool
operator==(const error_code& __lhs, const error_code& __rhs) operator==(const error_code& __lhs, const error_code& __rhs) noexcept
{ return (__lhs.category() == __rhs.category() { return (__lhs.category() == __rhs.category()
&& __lhs.value() == __rhs.value()); } && __lhs.value() == __rhs.value()); }
inline bool inline bool
operator==(const error_code& __lhs, const error_condition& __rhs) operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
{ {
return (__lhs.category().equivalent(__lhs.value(), __rhs) return (__lhs.category().equivalent(__lhs.value(), __rhs)
|| __rhs.category().equivalent(__lhs, __rhs.value())); || __rhs.category().equivalent(__lhs, __rhs.value()));
} }
inline bool inline bool
operator==(const error_condition& __lhs, const error_code& __rhs) operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
{ {
return (__rhs.category().equivalent(__rhs.value(), __lhs) return (__rhs.category().equivalent(__rhs.value(), __lhs)
|| __lhs.category().equivalent(__rhs, __lhs.value())); || __lhs.category().equivalent(__rhs, __lhs.value()));
} }
inline bool inline bool
operator==(const error_condition& __lhs, const error_condition& __rhs) operator==(const error_condition& __lhs,
const error_condition& __rhs) noexcept
{ {
return (__lhs.category() == __rhs.category() return (__lhs.category() == __rhs.category()
&& __lhs.value() == __rhs.value()); && __lhs.value() == __rhs.value());
} }
inline bool inline bool
operator!=(const error_code& __lhs, const error_code& __rhs) operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
{ return !(__lhs == __rhs); } { return !(__lhs == __rhs); }
inline bool inline bool
operator!=(const error_code& __lhs, const error_condition& __rhs) operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
{ return !(__lhs == __rhs); } { return !(__lhs == __rhs); }
inline bool inline bool
operator!=(const error_condition& __lhs, const error_code& __rhs) operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
{ return !(__lhs == __rhs); } { return !(__lhs == __rhs); }
inline bool inline bool
operator!=(const error_condition& __lhs, const error_condition& __rhs) operator!=(const error_condition& __lhs,
const error_condition& __rhs) noexcept
{ return !(__lhs == __rhs); } { return !(__lhs == __rhs); }
...@@ -338,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -338,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
virtual ~system_error() throw(); virtual ~system_error() throw();
const error_code& const error_code&
code() const throw() { return _M_code; } code() const noexcept { return _M_code; }
}; };
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
......
...@@ -37,7 +37,7 @@ namespace ...@@ -37,7 +37,7 @@ namespace
generic_error_category() {} generic_error_category() {}
virtual const char* virtual const char*
name() const name() const noexcept
{ return "generic"; } { return "generic"; }
virtual string virtual string
...@@ -54,7 +54,7 @@ namespace ...@@ -54,7 +54,7 @@ namespace
system_error_category() {} system_error_category() {}
virtual const char* virtual const char*
name() const name() const noexcept
{ return "system"; } { return "system"; }
virtual string virtual string
...@@ -74,32 +74,33 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -74,32 +74,33 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
error_category::error_category() = default; error_category::error_category() noexcept = default;
error_category::~error_category() = default; error_category::~error_category() noexcept = default;
const error_category& const error_category&
system_category() throw() { return system_category_instance; } system_category() noexcept { return system_category_instance; }
const error_category& const error_category&
generic_category() throw() { return generic_category_instance; } generic_category() noexcept { return generic_category_instance; }
system_error::~system_error() throw() = default; system_error::~system_error() noexcept = default;
error_condition error_condition
error_category::default_error_condition(int __i) const error_category::default_error_condition(int __i) const noexcept
{ return error_condition(__i, *this); } { return error_condition(__i, *this); }
bool bool
error_category::equivalent(int __i, const error_condition& __cond) const error_category::equivalent(int __i,
const error_condition& __cond) const noexcept
{ return default_error_condition(__i) == __cond; } { return default_error_condition(__i) == __cond; }
bool bool
error_category::equivalent(const error_code& __code, int __i) const error_category::equivalent(const error_code& __code, int __i) const noexcept
{ return *this == __code.category() && __code.value() == __i; } { return *this == __code.category() && __code.value() == __i; }
error_condition error_condition
error_code::default_error_condition() const error_code::default_error_condition() const noexcept
{ return category().default_error_condition(value()); } { return category().default_error_condition(value()); }
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -26,7 +26,7 @@ class my_error_category_impl ...@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category : public std::error_category
{ {
public: public:
const char* name() const { return ""; } const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; } std::string message(int) const { return ""; }
} my_error_category_instance; } my_error_category_instance;
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -26,7 +26,7 @@ class my_error_category_impl ...@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category : public std::error_category
{ {
public: public:
const char* name() const { return ""; } const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; } std::string message(int) const { return ""; }
} my_error_category_instance; } my_error_category_instance;
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -26,7 +26,7 @@ class my_error_category_impl ...@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category : public std::error_category
{ {
public: public:
const char* name() const { return ""; } const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; } std::string message(int) const { return ""; }
} my_error_category_instance; } my_error_category_instance;
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// Copyright (C) 2009 Free Software Foundation, Inc. // Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -26,7 +26,7 @@ class my_error_category_impl ...@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category : public std::error_category
{ {
public: public:
const char* name() const { return ""; } const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; } std::string message(int) const { return ""; }
} my_error_category_instance; } my_error_category_instance;
......
// -*- C++ -*- // -*- C++ -*-
// Error handling utils for the C++ library testsuite. // Error handling utils for the C++ library testsuite.
// //
// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -32,8 +32,8 @@ namespace __gnu_test ...@@ -32,8 +32,8 @@ namespace __gnu_test
test_category() {} test_category() {}
virtual const char* virtual const char*
name() const name() const noexcept
{ {
const char* s = "__gnu_test::test_category"; const char* s = "__gnu_test::test_category";
return s; return s;
} }
...@@ -48,8 +48,8 @@ namespace __gnu_test ...@@ -48,8 +48,8 @@ namespace __gnu_test
test_derived_category() {} test_derived_category() {}
virtual const char* virtual const char*
name() const name() const noexcept
{ {
const char* s = "__gnu_test::test_derived_category"; const char* s = "__gnu_test::test_derived_category";
return s; return s;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment