]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
system_error (is_error_code_enum): Specialize for errc.
authorChris Fairles <cfairles@gcc.gnu.org>
Wed, 22 Oct 2008 15:27:44 +0000 (15:27 +0000)
committerChris Fairles <cfairles@gcc.gnu.org>
Wed, 22 Oct 2008 15:27:44 +0000 (15:27 +0000)
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

24 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/config/os/generic/error_constants.h
libstdc++-v3/config/os/mingw32/error_constants.h
libstdc++-v3/include/std/mutex
libstdc++-v3/include/std/system_error
libstdc++-v3/src/functexcept.cc
libstdc++-v3/src/system_error.cc
libstdc++-v3/testsuite/19_diagnostics/error_category/cons/copy_neg.cc
libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.cc
libstdc++-v3/testsuite/19_diagnostics/error_code/operators/bool.cc
libstdc++-v3/testsuite/19_diagnostics/error_code/operators/equal.cc
libstdc++-v3/testsuite/19_diagnostics/error_code/operators/not_equal.cc
libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/1.cc
libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/bool.cc
libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/equal.cc
libstdc++-v3/testsuite/19_diagnostics/error_condition/operators/not_equal.cc
libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc [new file with mode: 0644]
libstdc++-v3/testsuite/19_diagnostics/headers/system_error/types_std_c++0x.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/error_code.cc
libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc

index 4531127d7ec7a51f0ca6a4d4f8939d53995c2619..256aa5bd3636bc1926fa1e5e0a4913c482165421 100644 (file)
@@ -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<>
index 024fcfd40869c172954c586b6f6b03d989e6f2e2..04262bae32cdc64fedcfd604ac02b55d1c0009db 100644 (file)
@@ -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;
index 644d111b70b1ba8ca4adab7f5a2c61f4b824d886..2304a4c16f119a8ca542ef715d041a7c610898f0 100644 (file)
@@ -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
 
index 27af22225d5733bf203f5807685d41e203eab557..00e63923f035e3f23d7dd5b41f0c5f2f17156bd8 100644 (file)
 
 _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
 
index f3848d09c0220553aeaa6fc06be312b02e241c99..e3922360b3d683378b2ff345251469b7424fa9cb 100644 (file)
@@ -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();
index 6a09ebf5272e5f552708c1acf71a5f5c3d6f3129..4a93e5fbbc7e8af731cb68deba0ded9e5988475a 100644 (file)
@@ -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)) { }
index 95b65bb326b9ae0ae23a3a71effe5909a3db5e59..266e035662a7e20fed56a6f83d3332f933eecd84 100644 (file)
@@ -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)
index 6724ef75a1f252e78e59a7d4e94cf5bdaa400e3c..dd950eba150b244775f1c6181ed01d6484cc9366 100644 (file)
 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 
index e73884cc35fbb1f306a4a61bc31ae6c60c3af43d..8adf3fefa6a43a0b89b7ccf92bb20e8f3cca6730 100644 (file)
@@ -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" }
index 9dc11b70a08d11f4383a50552ad675e9803af9d4..742eb4099255ecfa110caabef5a63bae594a87f6 100644 (file)
@@ -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;
 }
index 04fd44fb6775574f9c011746f6d2ec6aaea84f46..385960ce0c135086c2a00472b8e86d23943634f5 100644 (file)
@@ -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 );
index a8fc65c4c3196139d53ee9b03a4598b71d58731a..8fcf1e59440e9b443af81c041be53fa4116da894 100644 (file)
@@ -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) );
index d5d75553bf57ce52aa9c9559ed8e0de30cb35366..aca79ada6b67cbad7a32141443f24f498a380581 100644 (file)
@@ -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 );
index 572d244954674e38be4109b2bf53d08899df86bf..5ea76f77a19763ff51c30a42ee3983838beeda49 100644 (file)
@@ -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()
index c1cda2626d4a937d2aeb8dfab1551525c05c76dd..d55256d564d9e303ba2bde735a246820b0282a8a 100644 (file)
@@ -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 );
index 4bdf36190a940d47ceca0b825ecaa6ba3ea7e3da..7d7c80f66c5bbfcc00217cbb6ed425f51e58738f 100644 (file)
@@ -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) );
index 1b78b0af029f02b5ae93da338b72ac46889ae395..50a4e90a6c9399c663a5fc969e9acc0338ae69d4 100644 (file)
@@ -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 (file)
index 0000000..d2325d1
--- /dev/null
@@ -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);
+}
index 00a24572fbdc2bcd4dc8fe1f2a134614c9cd267f..416d849b14f53b0b577b5078d1ffa31066f66212 100644 (file)
@@ -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;
 }
index 9fc24f1f25d702651accd359369462504d1d63dd..bf73398616be51dfb4da24750b97edd8359da3c4 100644 (file)
@@ -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
   {
index 5934982fa479a093b3f768934c06a221245a8195..e7304a1036ea51e7d8d5a518d59e0e082ce12885 100644 (file)
@@ -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 );
index e4814d6f5d92718908e4b82038b35a771399becc..82031316859f1f9c67da522b05347a381790d572 100644 (file)
@@ -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;
 
   {
index 73c838b4399fdbb87cf089d2de985b647a4f3c68..7cd416598f30fb3027e061bfecb1d915c01a7e8f 100644 (file)
@@ -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;
 
   {
index 2a3aa17c5e8e9b7c8bff8300fc8154e36fb6d2e6..e2599eb5c5e7d456568dfa69963e4b24e54ef8fd 100644 (file)
@@ -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 (...)
        {