From patchwork Wed Jul 20 18:19:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 105777 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D9406B6F6F for ; Thu, 21 Jul 2011 04:19:17 +1000 (EST) Received: (qmail 9297 invoked by alias); 20 Jul 2011 18:19:15 -0000 Received: (qmail 9281 invoked by uid 22791); 20 Jul 2011 18:19:12 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from smtp209.alice.it (HELO smtp209.alice.it) (82.57.200.105) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Jul 2011 18:18:56 +0000 Received: from [192.168.1.4] (79.47.193.122) by smtp209.alice.it (8.5.124.08) id 4DE658F804D77B64; Wed, 20 Jul 2011 20:18:54 +0200 Message-ID: <4E271C19.7030804@oracle.com> Date: Wed, 20 Jul 2011 20:19:05 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Use noexcept in X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, tested x86_64-linux multilib, committed. Thanks, Paolo. //////////////////// 2011-07-20 Paolo Carlini * 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. Index: src/system_error.cc =================================================================== --- src/system_error.cc (revision 176525) +++ src/system_error.cc (working copy) @@ -37,7 +37,7 @@ generic_error_category() {} virtual const char* - name() const + name() const noexcept { return "generic"; } virtual string @@ -54,7 +54,7 @@ system_error_category() {} virtual const char* - name() const + name() const noexcept { return "system"; } virtual string @@ -74,32 +74,33 @@ { _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 Index: include/std/system_error =================================================================== --- include/std/system_error (revision 176525) +++ include/std/system_error (working copy) @@ -66,47 +66,47 @@ 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()(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 struct hash; @@ -115,49 +115,49 @@ // 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 - error_code(_ErrorCodeEnum __e, - typename enable_if::value>::type* = 0) + template::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 enable_if::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 @@ // 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(__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 @@ 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 - error_condition(_ErrorConditionEnum __e, - typename enable_if::value>::type* = 0) + template::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 @@ template typename enable_if::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 @@ // 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(__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 @@ // 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 @@ virtual ~system_error() throw(); const error_code& - code() const throw() { return _M_code; } + code() const noexcept { return _M_code; } }; _GLIBCXX_END_NAMESPACE_VERSION Index: testsuite/19_diagnostics/error_condition/modifiers/39881.cc =================================================================== --- testsuite/19_diagnostics/error_condition/modifiers/39881.cc (revision 176525) +++ testsuite/19_diagnostics/error_condition/modifiers/39881.cc (working copy) @@ -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 @@ : 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; Index: testsuite/19_diagnostics/error_condition/cons/39881.cc =================================================================== --- testsuite/19_diagnostics/error_condition/cons/39881.cc (revision 176525) +++ testsuite/19_diagnostics/error_condition/cons/39881.cc (working copy) @@ -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 @@ : 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; Index: testsuite/19_diagnostics/error_code/modifiers/39882.cc =================================================================== --- testsuite/19_diagnostics/error_code/modifiers/39882.cc (revision 176525) +++ testsuite/19_diagnostics/error_code/modifiers/39882.cc (working copy) @@ -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 @@ : 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; Index: testsuite/19_diagnostics/error_code/cons/39882.cc =================================================================== --- testsuite/19_diagnostics/error_code/cons/39882.cc (revision 176525) +++ testsuite/19_diagnostics/error_code/cons/39882.cc (working copy) @@ -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 @@ : 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; Index: testsuite/util/testsuite_error.h =================================================================== --- testsuite/util/testsuite_error.h (revision 176525) +++ testsuite/util/testsuite_error.h (working copy) @@ -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 @@ test_category() {} virtual const char* - name() const - { + name() const noexcept + { const char* s = "__gnu_test::test_category"; return s; } @@ -48,8 +48,8 @@ test_derived_category() {} virtual const char* - name() const - { + name() const noexcept + { const char* s = "__gnu_test::test_derived_category"; return s; }