aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2011-07-20 18:17:30 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-07-20 18:17:30 +0000
commitcd88bb8c771788c4f3ad2f1be42e99db5e4a90fe (patch)
tree65be25078ab37ec701d000ff4a8f1f66c3db81ae
parentd05f35643be286f2cb4c10284d053ec13f48de04 (diff)
downloadgcc-cd88bb8c771788c4f3ad2f1be42e99db5e4a90fe.zip
gcc-cd88bb8c771788c4f3ad2f1be42e99db5e4a90fe.tar.gz
gcc-cd88bb8c771788c4f3ad2f1be42e99db5e4a90fe.tar.bz2
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
-rw-r--r--libstdc++-v3/ChangeLog14
-rw-r--r--libstdc++-v3/include/std/system_error104
-rw-r--r--libstdc++-v3/src/system_error.cc23
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc4
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc4
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc4
-rw-r--r--libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc4
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_error.h10
8 files changed, 92 insertions, 75 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 7522ba8..62d1511 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+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>
* include/precompiled/stdc++.h: Add scoped_allocator.
diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error
index da09a75..565261e 100644
--- a/libstdc++-v3/include/std/system_error
+++ b/libstdc++-v3/include/std/system_error
@@ -66,47 +66,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class error_category
{
protected:
- error_category();
+ error_category() noexcept;
public:
- virtual ~error_category();
+ virtual ~error_category() noexcept;
error_category(const error_category&) = delete;
error_category& operator=(const error_category&) = delete;
virtual const char*
- name() const = 0;
+ name() const noexcept = 0;
virtual string
message(int) const = 0;
virtual error_condition
- default_error_condition(int __i) const;
+ default_error_condition(int __i) const noexcept;
virtual bool
- equivalent(int __i, const error_condition& __cond) const;
+ equivalent(int __i, const error_condition& __cond) const noexcept;
virtual bool
- equivalent(const error_code& __code, int __i) const;
+ equivalent(const error_code& __code, int __i) const noexcept;
bool
- operator<(const error_category& __other) const
+ operator<(const error_category& __other) const noexcept
{ return less<const error_category*>()(this, &__other); }
bool
- operator==(const error_category& __other) const
+ operator==(const error_category& __other) const noexcept
{ return this == &__other; }
bool
- operator!=(const error_category& __other) const
+ operator!=(const error_category& __other) const noexcept
{ return this != &__other; }
};
// DR 890.
- _GLIBCXX_CONST const error_category& system_category() throw();
- _GLIBCXX_CONST const error_category& generic_category() throw();
+ _GLIBCXX_CONST const error_category& system_category() noexcept;
+ _GLIBCXX_CONST const error_category& generic_category() noexcept;
- error_code make_error_code(errc);
+ error_code make_error_code(errc) noexcept;
template<typename _Tp>
struct hash;
@@ -115,49 +115,49 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Implementation-specific error identification
struct error_code
{
- error_code()
+ error_code() noexcept
: _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) { }
- template<typename _ErrorCodeEnum>
- error_code(_ErrorCodeEnum __e,
- typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0)
+ template<typename _ErrorCodeEnum, typename = typename
+ enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type>
+ error_code(_ErrorCodeEnum __e) noexcept
{ *this = make_error_code(__e); }
void
- assign(int __v, const error_category& __cat)
+ assign(int __v, const error_category& __cat) noexcept
{
_M_value = __v;
_M_cat = &__cat;
}
void
- clear()
+ clear() noexcept
{ assign(0, system_category()); }
// DR 804.
template<typename _ErrorCodeEnum>
typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value,
error_code&>::type
- operator=(_ErrorCodeEnum __e)
+ operator=(_ErrorCodeEnum __e) noexcept
{ return *this = make_error_code(__e); }
int
- value() const { return _M_value; }
+ value() const noexcept { return _M_value; }
const error_category&
- category() const { return *_M_cat; }
+ category() const noexcept { return *_M_cat; }
error_condition
- default_error_condition() const;
+ default_error_condition() const noexcept;
string
message() const
{ return category().message(value()); }
- explicit operator bool() const
+ explicit operator bool() const noexcept
{ return _M_value != 0 ? true : false; }
// DR 804.
@@ -170,11 +170,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 19.4.2.6 non-member functions
inline error_code
- make_error_code(errc __e)
+ make_error_code(errc __e) noexcept
{ return error_code(static_cast<int>(__e), generic_category()); }
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()
|| (__lhs.category() == __rhs.category()
@@ -186,26 +186,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
{ return (__os << __e.category().name() << ':' << __e.value()); }
- error_condition make_error_condition(errc);
+ error_condition make_error_condition(errc) noexcept;
/// error_condition
// Portable error identification
struct error_condition
{
- error_condition()
+ error_condition() noexcept
: _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) { }
- template<typename _ErrorConditionEnum>
- error_condition(_ErrorConditionEnum __e,
- typename enable_if<is_error_condition_enum
- <_ErrorConditionEnum>::value>::type* = 0)
+ template<typename _ErrorConditionEnum, typename = typename
+ enable_if<is_error_condition_enum<_ErrorConditionEnum>::value>::type>
+ error_condition(_ErrorConditionEnum __e) noexcept
{ *this = make_error_condition(__e); }
void
- assign(int __v, const error_category& __cat)
+ assign(int __v, const error_category& __cat) noexcept
{
_M_value = __v;
_M_cat = &__cat;
@@ -215,25 +214,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ErrorConditionEnum>
typename enable_if<is_error_condition_enum
<_ErrorConditionEnum>::value, error_condition&>::type
- operator=(_ErrorConditionEnum __e)
+ operator=(_ErrorConditionEnum __e) noexcept
{ return *this = make_error_condition(__e); }
void
- clear()
+ clear() noexcept
{ assign(0, generic_category()); }
// 19.4.3.4 observers
- int
- value() const { return _M_value; }
+ int
+ value() const noexcept { return _M_value; }
const error_category&
- category() const { return *_M_cat; }
+ category() const noexcept { return *_M_cat; }
string
message() const
{ return category().message(value()); }
- explicit operator bool() const
+ explicit operator bool() const noexcept
{ return _M_value != 0 ? true : false; }
// DR 804.
@@ -244,11 +243,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 19.4.3.6 non-member functions
inline error_condition
- make_error_condition(errc __e)
+ make_error_condition(errc __e) noexcept
{ return error_condition(static_cast<int>(__e), generic_category()); }
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()
|| (__lhs.category() == __rhs.category()
@@ -257,45 +257,47 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 19.4.4 Comparison operators
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()
&& __lhs.value() == __rhs.value()); }
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)
|| __rhs.category().equivalent(__lhs, __rhs.value()));
}
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)
|| __lhs.category().equivalent(__rhs, __lhs.value()));
}
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()
&& __lhs.value() == __rhs.value());
}
inline bool
- operator!=(const error_code& __lhs, const error_code& __rhs)
+ operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
{ return !(__lhs == __rhs); }
inline bool
- operator!=(const error_code& __lhs, const error_condition& __rhs)
+ operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
{ return !(__lhs == __rhs); }
inline bool
- operator!=(const error_condition& __lhs, const error_code& __rhs)
+ operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
{ return !(__lhs == __rhs); }
inline bool
- operator!=(const error_condition& __lhs, const error_condition& __rhs)
+ operator!=(const error_condition& __lhs,
+ const error_condition& __rhs) noexcept
{ return !(__lhs == __rhs); }
@@ -338,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
virtual ~system_error() throw();
const error_code&
- code() const throw() { return _M_code; }
+ code() const noexcept { return _M_code; }
};
_GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/src/system_error.cc b/libstdc++-v3/src/system_error.cc
index 5d9c6f5..8186199 100644
--- a/libstdc++-v3/src/system_error.cc
+++ b/libstdc++-v3/src/system_error.cc
@@ -37,7 +37,7 @@ namespace
generic_error_category() {}
virtual const char*
- name() const
+ name() const noexcept
{ return "generic"; }
virtual string
@@ -54,7 +54,7 @@ namespace
system_error_category() {}
virtual const char*
- name() const
+ name() const noexcept
{ return "system"; }
virtual string
@@ -74,32 +74,33 @@ namespace std _GLIBCXX_VISIBILITY(default)
{
_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&
- system_category() throw() { return system_category_instance; }
+ system_category() noexcept { return system_category_instance; }
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_category::default_error_condition(int __i) const
+ error_category::default_error_condition(int __i) const noexcept
{ return error_condition(__i, *this); }
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; }
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; }
error_condition
- error_code::default_error_condition() const
+ error_code::default_error_condition() const noexcept
{ return category().default_error_condition(value()); }
_GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc
index 9d5c2e3..3edb766 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/39882.cc
@@ -1,6 +1,6 @@
// { 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
// software; you can redistribute it and/or modify it under the
@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category
{
public:
- const char* name() const { return ""; }
+ const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; }
} my_error_category_instance;
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc
index 880a936..9755ba1 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/modifiers/39882.cc
@@ -1,6 +1,6 @@
// { 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
// software; you can redistribute it and/or modify it under the
@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category
{
public:
- const char* name() const { return ""; }
+ const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; }
} my_error_category_instance;
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc
index 7931f17..f41f746 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/39881.cc
@@ -1,6 +1,6 @@
// { 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
// software; you can redistribute it and/or modify it under the
@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category
{
public:
- const char* name() const { return ""; }
+ const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; }
} my_error_category_instance;
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc
index 0178a91..ddd488e 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/modifiers/39881.cc
@@ -1,6 +1,6 @@
// { 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
// software; you can redistribute it and/or modify it under the
@@ -26,7 +26,7 @@ class my_error_category_impl
: public std::error_category
{
public:
- const char* name() const { return ""; }
+ const char* name() const noexcept { return ""; }
std::string message(int) const { return ""; }
} my_error_category_instance;
diff --git a/libstdc++-v3/testsuite/util/testsuite_error.h b/libstdc++-v3/testsuite/util/testsuite_error.h
index c2bfed7..bb9ddd7 100644
--- a/libstdc++-v3/testsuite/util/testsuite_error.h
+++ b/libstdc++-v3/testsuite/util/testsuite_error.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
// 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
// software; you can redistribute it and/or modify it under the
@@ -32,8 +32,8 @@ namespace __gnu_test
test_category() {}
virtual const char*
- name() const
- {
+ name() const noexcept
+ {
const char* s = "__gnu_test::test_category";
return s;
}
@@ -48,8 +48,8 @@ namespace __gnu_test
test_derived_category() {}
virtual const char*
- name() const
- {
+ name() const noexcept
+ {
const char* s = "__gnu_test::test_derived_category";
return s;
}