]> gcc.gnu.org Git - gcc.git/commitdiff
system_error: Align to current draft specifications.
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 16 May 2008 21:55:00 +0000 (21:55 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 16 May 2008 21:55:00 +0000 (21:55 +0000)
2008-05-16  Benjamin Kosnik  <bkoz@redhat.com>

* include/std/system_error: Align to current draft specifications.
* src/system_error.cc: Same.
* src/functexcept.cc: Adjust for corrected system_error construction.
* include/std/ostream: Adjust error_code inserter.
* acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): Remove sys_nerr test.
* config/abi/pre/gnu.ver: Add new exports.

* testsuite/util/testsuite_error.h: Consolidate error testing
utilities here.
* testsuite/19_diagnostics/error_code/cons/1.cc: Use
testsuite_error, adjust line numbers and constructor calls.
* testsuite/19_diagnostics/error_code/operators/equal.cc: Same.
* testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same.
* testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same.
* testsuite/19_diagnostics/error_category/cons/default.cc: Same.
* testsuite/19_diagnostics/error_category/operators/equal.cc: Same.
* testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same.
* testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc:
Same.
* testsuite/19_diagnostics/system_error/cons-1.cc: Same.
* testsuite/19_diagnostics/system_error/what-1.cc: Same.
* testsuite/19_diagnostics/system_error/what-2.cc: Same.
* testsuite/19_diagnostics/system_error/what-big.cc: Same.
* testsuite/19_diagnostics/system_error/what-3.cc: Same.
* testsuite/19_diagnostics/system_error/what-4.cc: Same.

From-SVN: r135446

22 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/acinclude.m4
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/include/std/ostream
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_category/cons/default.cc
libstdc++-v3/testsuite/19_diagnostics/error_category/operators/equal.cc
libstdc++-v3/testsuite/19_diagnostics/error_category/operators/not_equal.cc
libstdc++-v3/testsuite/19_diagnostics/error_code/cons/1.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/system_error/cons-1.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc
libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc
libstdc++-v3/testsuite/util/testsuite_error.h [new file with mode: 0644]

index 88a038d1b163e9a745f9d5eb5bf2801e4f5a3d0d..1a32e5572e457396a7f92b93d5ebd04b7a938ce7 100644 (file)
@@ -1,3 +1,31 @@
+2008-05-16  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/std/system_error: Align to current draft specifications.
+       * src/system_error.cc: Same.
+       * src/functexcept.cc: Adjust for corrected system_error construction.
+       * include/std/ostream: Adjust error_code inserter.
+       * acinclude.m4 (GLIBCXX_CHECK_SYSTEM_ERROR): Remove sys_nerr test.
+       * config/abi/pre/gnu.ver: Add new exports.
+       
+       * testsuite/util/testsuite_error.h: Consolidate error testing
+       utilities here.
+       * testsuite/19_diagnostics/error_code/cons/1.cc: Use
+       testsuite_error, adjust line numbers and constructor calls.
+       * testsuite/19_diagnostics/error_code/operators/equal.cc: Same.
+       * testsuite/19_diagnostics/error_code/operators/not_equal.cc: Same.
+       * testsuite/19_diagnostics/error_category/cons/copy_neg.cc: Same.
+       * testsuite/19_diagnostics/error_category/cons/default.cc: Same.
+       * testsuite/19_diagnostics/error_category/operators/equal.cc: Same.
+       * testsuite/19_diagnostics/error_category/operators/not_equal.cc: Same.
+       * testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc: 
+       Same.
+       * testsuite/19_diagnostics/system_error/cons-1.cc: Same.
+       * testsuite/19_diagnostics/system_error/what-1.cc: Same.
+       * testsuite/19_diagnostics/system_error/what-2.cc: Same.
+       * testsuite/19_diagnostics/system_error/what-big.cc: Same.
+       * testsuite/19_diagnostics/system_error/what-3.cc: Same.
+       * testsuite/19_diagnostics/system_error/what-4.cc: Same.
+
 2008-05-15  Bernd Schmidt  <bernd.schmidt@analog.com>
 
        * configure.ac: Don't check AC_LIBTOOL_DLOPEN if using newlib.
index 022548b07db6f329dcfcaec443dd8e79aecac717..db3c7b19b252dca31d707a5be1b51fe7b4a4c16f 100644 (file)
@@ -1327,7 +1327,7 @@ AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
 
 m4_pushdef([n_syserr], [1])dnl
 m4_foreach([syserr], [EOWNERDEAD, ENOTRECOVERABLE, ENOLINK, EPROTO, ENODATA,
-                     ENOSR, ENOSTR, ETIME, sys_nerr, EBADMSG, ECANCELED,
+                     ENOSR, ENOSTR, ETIME, EBADMSG, ECANCELED,
                      EOVERFLOW, ENOTSUP, EIDRM, ETXTBSY],
 [m4_pushdef([SYSERR], m4_toupper(syserr))dnl
 AC_MSG_CHECKING([for syserr])
index 48b8cfd0aae0a216bdc999c3078fc62bdfe48163..225e6e5c71fd485be4701f8cb1156eaebd9fefb9 100644 (file)
@@ -70,7 +70,9 @@ GLIBCXX_3.4 {
 #     std::[d-g]*;
       std::d[a-d]*;
       std::d[f-z]*;
-      std::e*;
+      std::e[a-q]*;
+      std::error[^_]*;
+      std::e[s-z]*;
       std::gslice*;
       std::h[^a]*;
       std::i[a-n]*;
@@ -854,7 +856,14 @@ GLIBCXX_3.4.11 {
     _ZNSt18condition_variableD2Ev;
 
     # system_error
-    _ZSt15system_category;
+    _ZSt18get_posix_categoryv;
+    _ZSt19get_system_categoryv;
+
+    _ZNKSt10error_code23default_error_conditionEv;
+    _ZNKSt14error_category23default_error_conditionEi;
+
+    _ZNKSt14error_category10equivalentERKSt10error_codei;
+    _ZNKSt14error_category10equivalentEiRKSt15error_condition;
 
     _ZTISt14error_category;
     _ZTSSt14error_category;
index ffbb0e121f41e1dfd4c735ef3c4f9f10f6a7f811..c0120fa2f053bc0d158be4d8752ee503140ea6a9 100644 (file)
@@ -539,7 +539,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   template<typename _CharT, typename _Traits>
     inline basic_ostream<_CharT, _Traits>&
     operator<<(basic_ostream<_CharT, _Traits>& __out, const error_code& __e)
-    { return (__out << __e.category().name().c_str() << ':' << __e.value()); }
+    { return (__out << __e.category().name() << ':' << __e.value()); }
 #endif
 
   // [27.6.2.7] standard basic_ostream manipulators
index 5081e3f11ec3800633e8c48917e5e13a7c48b02b..ac3b1f75b61f01148c68d5c14887e95cc93c4ecf 100644 (file)
 
 _GLIBCXX_BEGIN_NAMESPACE(std)
 
-  class system_error;
   class error_code;
+  class error_condition;
   class error_category;
+  class system_error;
+
+  /// is_error_code_enum
+  template<typename _T>
+    struct is_error_code_enum : public false_type { };
+
+  template<> 
+    struct is_error_code_enum<posix_error::posix_errno>
+    : public true_type { };
+
+  /// is_error_condition_enum
+  template<typename _T>
+    struct is_error_condition_enum : public false_type { };
+
+  template<> 
+    struct is_error_condition_enum<posix_error::posix_errno>
+    : public true_type { };
 
-  extern const error_category& system_category;
 
   /// error_category
   struct error_category
   {
     error_category() { }
 
+    virtual const char* 
+    name() const = 0;
+
+    virtual string 
+    message(int) const = 0;
+
+    virtual error_condition
+    default_error_condition(int __i) const;
+
+    virtual bool 
+    equivalent(int __i, const error_condition& __cond) const;
+
+    virtual bool 
+    equivalent(const error_code& __code, int __i) const;
+
+    bool 
+    operator<(const error_category& __other) const
+    { return less<const error_category*>()(this, &__other); }
+
     bool 
     operator==(const error_category& __other) const
     { return this == &__other; }
@@ -66,12 +101,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     operator!=(const error_category& __other) const
     { return this != &__other; }
 
-    virtual posix_error::posix_errno 
-    posix(int __v) const = 0;
-
-    virtual const string& 
-    name() const = 0;
-
   private:
     error_category(const error_category&);
 
@@ -79,40 +108,59 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     operator=(const error_category&);
   };
 
+  const error_category& get_posix_category();
+  const error_category& get_system_category();
+
+  static const error_category& system_category = get_system_category();
+  static const error_category& native_category = get_posix_category();
+
   /// error_code
+  // Implementation-specific error identification
   struct error_code
   {
-    error_code() throw()
+    error_code()
     : _M_value(0), _M_cat(&system_category) { }
 
-    error_code(int __v, const error_category& __cat) throw()
+    error_code(int __v, const error_category& __cat)
     : _M_value(__v), _M_cat(&__cat) { }
 
-    error_code(posix_error::posix_errno __v)
-    : _M_value(__v), _M_cat(&system_category) { }
+    template<typename _ErrorCodeEnum>
+      error_code(_ErrorCodeEnum __e,
+      typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type* = 0)
+      : _M_value(__e), _M_cat(&system_category)
+      { }
 
     void 
-    assign(int __v, const error_category& __cat) throw()
+    assign(int __v, const error_category& __cat)
     {
       _M_value = __v;
       _M_cat = &__cat; 
     }
 
     void 
-    clear() throw()
+    clear()
     { 
       _M_value = 0;
       _M_cat = &system_category;
-   } 
+    } 
+
+    template<typename _ErrorCodeEnum>
+      typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type&
+      operator=(_ErrorCodeEnum __e)
+      { _M_value = __e; }
 
     int
-    value() const throw() { return _M_value; }
+    value() const { return _M_value; }
       
     const error_category&  
     category() const { return *_M_cat; }
 
-    posix_error::posix_errno            
-    posix() const throw() { return this->category().posix(_M_value); }
+    error_condition 
+    default_error_condition() const;
+
+    string 
+    message() const
+    { return category().message(value()); }
 
     // Safe bool idiom.
     // explicit operator bool() const throw()
@@ -121,20 +169,127 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
     static void __not_bool_type() { }
 
-    operator __bool_type() const throw()
+    operator __bool_type() const
     { return _M_value != 0 ? &__not_bool_type : false; }
 
-    bool operator==(const error_code& __other) const
-    { return value() == __other.value() && category() == __other.category(); }
-
-    bool operator!=(const error_code& __other) const
-    { return !(this == &__other); }
-
   private:
     int                        _M_value;
     const error_category*      _M_cat;
   };
 
+  error_code 
+  make_error_code(posix_error::posix_errno);
+
+  // 19.4.2.5 non-member functions
+  bool operator<(const error_code& lhs, const error_code& rhs);
+
+  template<typename charT, typename traits>
+    basic_ostream<charT,traits>&
+    operator<<(basic_ostream<charT,traits>& os, const error_code& __code);
+
+
+  /// error_condition
+  // Portable error identification
+  struct error_condition 
+  {
+    error_condition() : _M_value(0), _M_cat(system_category) { }
+
+    error_condition(int __v, const error_category& __cat)     
+    : _M_value(__v), _M_cat(__cat) { }
+
+    template<typename _ErrorEnum>
+      error_condition(typename enable_if<is_error_condition_enum<_ErrorEnum>::value, _ErrorEnum>::type __v) : _M_value(__v), _M_cat(system_category) { }
+
+    void 
+    assign(int val, const error_category& cat);
+
+    template<typename _ErrorEnum>
+      error_condition&
+      operator=(typename enable_if<is_error_condition_enum<_ErrorEnum>::value, _ErrorEnum>::type __v)
+      { _M_value = __v; }
+
+    void 
+    clear();
+
+    // 19.4.3.4 observers
+    int 
+    value() const { return _M_value; }
+
+    const error_category& 
+    category() const { return _M_cat; }
+
+    string 
+    message() const
+    { return category().message(value()); }
+
+    // Safe bool idiom.
+    // explicit operator bool() const throw()
+    // { return _M_value != 0; }
+    typedef void (*__bool_type)();
+
+    static void __not_bool_type() { }
+
+    operator __bool_type() const
+    { return _M_value != 0 ? &__not_bool_type : false; }
+
+  private:
+    int                        _M_value;
+    const error_category&      _M_cat;
+  };
+
+  error_condition 
+  make_error_condition(posix_error::posix_errno);
+
+  // 19.4.3.5 non-member functions
+  inline bool 
+  operator<(const error_condition& lhs, const error_condition& rhs)
+  { 
+    bool __t1 = lhs.category() < rhs.category();
+    bool __t2 = lhs.category() == rhs.category() && lhs.value() < rhs.value();
+    return __t1 || __t2;
+  }
+
+  // 19.4.4 Comparison operators
+  inline bool 
+  operator==(const error_code& lhs, const error_code& rhs)
+  { return lhs.category() == rhs.category() && lhs.value() == rhs.value(); }
+
+  inline bool 
+  operator==(const error_code& lhs, const error_condition& rhs)
+  {
+    bool __t1 = lhs.category().equivalent(lhs.value(), rhs);
+    bool __t2 = rhs.category().equivalent(lhs, rhs.value());
+    return __t1 || __t2;
+  }
+
+  inline bool 
+  operator==(const error_condition& lhs, const error_code& rhs)
+  {
+    bool __t1 = rhs.category().equivalent(rhs.value(), lhs);
+    bool __t2 = lhs.category().equivalent(rhs, lhs.value());
+    return __t1 || __t2;
+  }
+
+  inline bool 
+  operator==(const error_condition& lhs, const error_condition& rhs)
+  { return lhs.category() == rhs.category() && lhs.value() == rhs.value(); }
+
+  inline bool 
+  operator!=(const error_code& lhs, const error_code& rhs)
+  { return !(lhs == rhs); }
+
+  inline bool 
+  operator!=(const error_code& lhs, const error_condition& rhs)
+  { return !(lhs == rhs); }
+
+  inline bool 
+  operator!=(const error_condition& lhs, const error_code& rhs)
+  { return !(lhs == rhs); }
+
+  inline bool 
+  operator!=(const error_condition& lhs, const error_condition& rhs)
+  { return !(lhs == rhs); }
+
   /// Thrown to indicate error code of underlying system.
   class system_error : public std::runtime_error
   {
@@ -145,10 +300,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     system_error(error_code __ec = error_code())
     : runtime_error(""), _M_code(__ec) { }
 
-    system_error(const string& __what, error_code __ec = error_code())
+    system_error(error_code __ec, const string& __what)
     : runtime_error(__what), _M_code(__ec) { }
 
-    system_error(const string& __what, int __v, const error_category& __ecat)
+    system_error(int __v, const error_category& __ecat)
+    : runtime_error(""), _M_code(error_code(__v, __ecat)) { }
+
+    system_error(int __v, const error_category& __ecat, const string& __what)
     : runtime_error(__what), _M_code(error_code(__v, __ecat)) { }
 
     virtual ~system_error() throw();
index f77bb0d29cdad6a49ae270ba0ae5bfcff131bd43..95b65bb326b9ae0ae23a3a71effe5909a3db5e59 100644 (file)
@@ -98,7 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
   void
   __throw_system_error(const char* __s)
-  { throw system_error(_(__s)); }
+  { throw system_error(error_code(), _(__s)); }
 
   void
   __throw_system_error(int __i)
index 81e73fcc7f998af7a57a699ea1bac9c22091d58e..6724ef75a1f252e78e59a7d4e94cf5bdaa400e3c 100644 (file)
@@ -1,6 +1,6 @@
 // <system_error> implementation file
 
-// Copyright (C) 2007
+// Copyright (C) 2007, 2008
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 
 namespace
 {
+  using std::string; 
+
   struct gnu_error_category : public std::error_category
   {
-    virtual const std::string& 
+    virtual const char*
     name() const 
     { 
-      static const std::string category("GNU");
-      return category;
+      const char* s = "GNU";
+      return s;
     }
 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
+    virtual string 
+    message(int i) const
     {
-#ifdef _GLIBCXX_HAVE_SYS_NERR
-      const int last_errorno = sys_nerr;
-#else
-      const int last_errorno = std::numeric_limits<int>::max();
-#endif
-      if (__v > 0 && __v <= last_errorno)
-       return std::posix_error::posix_errno(__v);
-      else
-       return std::posix_error::no_posix_equivalent;
+      // XXX locale issues: how does one get or set loc.
+      // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc)
+      return string(strerror(i));
     }
   };
 
@@ -64,8 +60,28 @@ namespace
 
 _GLIBCXX_BEGIN_NAMESPACE(std)
 
-  const error_category& system_category = gnu_category;
+  const error_category& 
+  get_posix_category() { return gnu_category; }
+
+  const error_category& 
+  get_system_category() { return gnu_category; }
 
   system_error::~system_error() throw() { }
 
+  error_condition 
+  error_category::default_error_condition(int __i) const
+  { return error_condition(__i, *this); }
+
+  bool 
+  error_category::equivalent(int __i, const error_condition& __cond) const
+  { return default_error_condition(__i) == __cond; }
+
+  bool 
+  error_category::equivalent(const error_code& __code, int __i) const
+  { return *this == __code.category() && __code.value() == __i; }
+
+  error_condition 
+  error_code::default_error_condition() const
+  { return category().default_error_condition(value()); }
+
 _GLIBCXX_END_NAMESPACE
index 5a8ec640fefeae317419247fe6d020ed3cab93f6..b7635fee4c00ae09b317b672825cc253759d5f21 100644 (file)
@@ -2,7 +2,7 @@
 // { dg-do compile }
 // 2007-08-22 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
 // USA.
 
 #include <system_error>
-#include <testsuite_hooks.h>
-
-namespace __gnu_test
-{
-  struct test_category : public std::error_category
-  { 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
-    { return std::posix_error::posix_errno(__v); }
-
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_category");
-      return s;
-    }
-  };
-}
+#include <testsuite_error.h>
 
 int main()
 {
@@ -50,7 +33,7 @@ int main()
   return 0;
 }
 
-// { dg-error "is private" "" { target *-*-* } 76 }
-// { dg-error "within this context" "" { target *-*-* } 29 }
-// { dg-error "first required here" "" { target *-*-* } 48 }
+// { dg-error "is private" "" { target *-*-* } 105 }
+// { dg-error "within this context" "" { target *-*-* } 41 }
+// { dg-error "first required here" "" { target *-*-* } 31 }
 // { dg-excess-errors "copy constructor" }
index 1072cc63c6740138613db9d4b35f81b36c1276eb..50c4651613175dc12c4bb2ea32cf3695481a1e79 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2007-08-22 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
 // USA.
 
 #include <system_error>
-#include <testsuite_hooks.h>
-
-namespace __gnu_test
-{
-  struct test_category : public std::error_category
-  { 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
-    { return std::posix_error::posix_errno(__v); }
-
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_category");
-      return s;
-    }
-  };
-
-  struct test_derived_category : public test_category
-  { 
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_derived_category");
-      return s;
-    }
-  };
-}
+#include <testsuite_error.h>
 
 int main()
 {
index 7b8a19cd7e33d3c61975acc5e7ca4e97565f77a5..b900521cb214e9f4d659dffec3509b640ca58af0 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2007-08-22 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
 // USA.
 
 #include <system_error>
-#include <testsuite_hooks.h>
-
-namespace __gnu_test
-{
-  struct test_category : public std::error_category
-  { 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
-    { return std::posix_error::posix_errno(__v); }
-
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_category");
-      return s;
-    }
-  };
-
-  struct test_derived_category : public test_category
-  { 
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_derived_category");
-      return s;
-    }
-  };
-}
+#include <testsuite_error.h>
 
 int main()
 {
index 043c8a207a30910fdcb594c38a18be9262005170..eab9940d05677195e6ac05bc39240987ba9ef74f 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2007-08-22 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
 // USA.
 
 #include <system_error>
-#include <testsuite_hooks.h>
-
-namespace __gnu_test
-{
-  struct test_category : public std::error_category
-  { 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
-    { return std::posix_error::posix_errno(__v); }
-
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_category");
-      return s;
-    }
-  };
-
-  struct test_derived_category : public test_category
-  { 
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_derived_category");
-      return s;
-    }
-  };
-}
+#include <testsuite_error.h>
 
 int main()
 {
index ea1316d067afe924a04af540d79e45e2ef6653f0..8ba68d645e198d45e5de09678b79bda232672121 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2007-08-22 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
 // USA.
 
 #include <system_error>
-#include <testsuite_hooks.h>
-
-namespace __gnu_test
-{
-  struct test_category : public std::error_category
-  { 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
-    { return std::posix_error::posix_errno(__v); }
-
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_category");
-      return s;
-    }
-  };
-}
+#include <testsuite_error.h>
 
 int main()
 {
index a98ed9023a09b0e069dd6d6256b3b258d5bf2b50..a8fc65c4c3196139d53ee9b03a4598b71d58731a 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2007-08-22 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
 // USA.
 
 #include <system_error>
-#include <testsuite_hooks.h>
-
-namespace __gnu_test
-{
-  struct test_category : public std::error_category
-  { 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
-    { return std::posix_error::posix_errno(__v); }
-
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_category");
-      return s;
-    }
-  };
-}
+#include <testsuite_error.h>
 
 // unspecified bool operator positive tests
 int main()
index 00153456403ba71a59fc4061a2dde88e1d7fb81f..d5d75553bf57ce52aa9c9559ed8e0de30cb35366 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2007-08-22 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
 // USA.
 
 #include <system_error>
-#include <testsuite_hooks.h>
-
-namespace __gnu_test
-{
-  struct test_category : public std::error_category
-  { 
-    virtual std::posix_error::posix_errno 
-    posix(int __v) const
-    { return std::posix_error::posix_errno(__v); }
-
-    virtual const std::string& 
-    name() const 
-    { 
-      static std::string s("__gnu_test::test_category");
-      return s;
-    }
-  };
-}
+#include <testsuite_error.h>
 
 // unspecified bool operator positive tests
 int main()
index 2885dad27235d5363dc0535e16d03daefdfa38a4..9fc24f1f25d702651accd359369462504d1d63dd 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-options "-std=gnu++0x" }
 // 2007-06-05 Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
@@ -31,14 +31,14 @@ int main()
 
   // 1
   {
-    std::system_error err1(s, e);
+    std::system_error err1(e, s);
     VERIFY( err1.code() == e ); 
     VERIFY( std::strcmp(err1.runtime_error::what(), s.c_str()) == 0 );
   }
 
   // 2
   {
-    std::system_error err2(s, 95, std::system_category);
+    std::system_error err2(95, std::system_category, s);
     VERIFY( err2.code() == std::error_code(95, std::system_category) ); 
     VERIFY( std::strcmp(err2.runtime_error::what(), s.c_str()) == 0 );
   }
index 09ba2fd13e4e7a182e2437d50a281bd09c2518d0..8e67ce5edae1b0807006197b532a0468a674ddaa 100644 (file)
@@ -26,6 +26,6 @@
 int main()
 {
   typedef std::system_error test_type;
-  __gnu_test::diamond_derivation<test_type, false>::test();
+  __gnu_test::diamond_derivation<test_type, true>::test();
   return 0;
 }
index c178e542a3cc0141f2aab8894d25bac33444d403..aef2a95c4ed20fdcc4908e6a0780a4c06fcc09ba 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2007
+// Copyright (C) 2007, 2008
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 #include <cstring>
 #include <testsuite_hooks.h>
 
+using namespace std;
+
 // libstdc++/1972
 void test01()
 {
   bool test __attribute__((unused)) = true;
-  std::string s("lack of sunlight, no water error");
+  string s("lack of sunlight, no water error");
 
   // 1
-  std::system_error obj1 = std::system_error(s);
+  system_error obj1 = system_error(error_code(), s);
 
   // 2
-  std::system_error obj2(s);
+  system_error obj2(error_code(), s);
 
-  VERIFY( std::strcmp(obj1.what(), s.data()) == 0 );
-  VERIFY( std::strcmp(obj2.what(), s.data()) == 0 );
+  VERIFY( strcmp(obj1.what(), s.data()) == 0 );
+  VERIFY( strcmp(obj2.what(), s.data()) == 0 );
 }
 
 void test02()
 {
   bool test __attribute__((unused)) = true;
-  std::string s("lack of sunlight error");
-  std::system_error x(s);
+  string s("lack of sunlight error");
+  system_error x(error_code(), s);
   
-  VERIFY( std::strcmp(x.what(), s.data()) == 0 );
+  VERIFY( strcmp(x.what(), s.data()) == 0 );
 }
 
 int main(void)
index eb8e14c9cc1e02a453fd9ad421c6d3ddd14f16d0..2bb54fb8e265c21714c1c83d4c0f18b51f50f293 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2007
+// Copyright (C) 2007, 2008
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -30,7 +30,7 @@
 class fuzzy_logic : public std::system_error
 {
 public:
-  fuzzy_logic() : std::system_error("whoa") { }
+  fuzzy_logic() : std::system_error(std::error_code(), "whoa") { }
 };
 
 void test03()
index 23d99a87d94732e117641715e4b1b188bded17de..76d10b8e8281f39e22fb36128a3034f13f662ca6 100644 (file)
@@ -41,12 +41,12 @@ void test04()
   const std::string s("CA ISO emergency once again:immediate power down");
   const char* strlit1 = "wish I lived in Palo Alto";
   const char* strlit2 = "...or Santa Barbara";
-  std::system_error obj1(s);
+  std::system_error obj1(std::error_code(), s);
   
   // block 01
   {
     const std::string s2(strlit1);
-    std::system_error obj2(s2);
+    std::system_error obj2(std::error_code(), s2);
     obj1 = obj2;
   }
   allocate_on_stack();
@@ -55,7 +55,7 @@ void test04()
   // block 02
   {
     const std::string s3(strlit2);
-    std::system_error obj3 = std::system_error(s3);
+    std::system_error obj3 = std::system_error(std::error_code(), s3);
     obj1 = obj3;
   }
   allocate_on_stack();     
index 89570f047211d0c85c4d07b4af7d34d60b617c35..5934982fa479a093b3f768934c06a221245a8195 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2007
+// Copyright (C) 2007, 2008
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -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(s, std::posix_error::invalid_argument);
+  std::system_error obj = std::system_error(std::posix_error::invalid_argument, s);
   std::string s1(obj.what());
   std::string s2(obj.what());
   VERIFY( s1 == s2 );
index 765bcbf19fef176247fec01447a9298a34bca07a..ecf89526b32e83c3abf827c19559b079940db4df 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 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
@@ -30,7 +30,7 @@ void test01()
 
   bool test __attribute__((unused)) = true;
   const std::string xxx(10000, 'x');
-  test_type t(xxx);
+  test_type t(std::error_code(), xxx);
   VERIFY( std::strcmp(t.what(), xxx.c_str()) == 0 );
 }
 
diff --git a/libstdc++-v3/testsuite/util/testsuite_error.h b/libstdc++-v3/testsuite/util/testsuite_error.h
new file mode 100644 (file)
index 0000000..56d6418
--- /dev/null
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+// Error handling utils for the C++ library testsuite. 
+//
+// Copyright (C) 2007, 2008 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.
+//
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+
+#ifndef _TESTSUITE_ERROR_H
+#define _TESTSUITE_ERROR_H 1
+
+namespace __gnu_test
+{
+  using std::string;
+
+  struct test_category : public std::error_category
+  { 
+    virtual const char*
+    name() const 
+    { 
+      const char* s = "__gnu_test::test_category";
+      return s;
+    }
+
+    virtual string 
+    message(int) const
+    { return string("message to be determined"); }
+
+  };
+
+  struct test_derived_category : public test_category
+  { 
+    virtual const char*
+    name() const 
+    { 
+      const char* s = "__gnu_test::test_derived_category";
+      return s;
+    }
+  };
+
+}
+#endif
This page took 0.1481 seconds and 5 git commands to generate.