OSDN Git Service

2009-12-15 Jonathan Wakely <jwakely.gcc@gmail.com>
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Dec 2009 20:17:27 +0000 (20:17 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Dec 2009 20:17:27 +0000 (20:17 +0000)
* include/std/future (unique_future::get, promise::set_value): Remove
workaround for c++/34022.
(packaged_task::get_future, packaged_task::operator()): Use
__throw_bad_function_call.
* testsuite/30_threads/packaged_task/cons/assign_neg.cc: Adjust.
* testsuite/30_threads/packaged_task/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/promise/cons/assign_neg.cc: Likewise.
* testsuite/30_threads/promise/cons/copy_neg.cc: Likewise.
* testsuite/30_threads/shared_future/cons/assign_neg.cc: Likewise.
* testsuite/30_threads/unique_future/cons/assign_neg.cc: Likewise.
* testsuite/30_threads/unique_future/cons/copy_neg.cc: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155269 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/future
libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc
libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc
libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc
libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc

index 4605d04..4e77d33 100644 (file)
@@ -1,5 +1,19 @@
 2009-12-15  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
+       * include/std/future (unique_future::get, promise::set_value): Remove
+       workaround for c++/34022.
+       (packaged_task::get_future, packaged_task::operator()): Use
+       __throw_bad_function_call.
+       * testsuite/30_threads/packaged_task/cons/assign_neg.cc: Adjust.
+       * testsuite/30_threads/packaged_task/cons/copy_neg.cc: Likewise.
+       * testsuite/30_threads/promise/cons/assign_neg.cc: Likewise.
+       * testsuite/30_threads/promise/cons/copy_neg.cc: Likewise.
+       * testsuite/30_threads/shared_future/cons/assign_neg.cc: Likewise.
+       * testsuite/30_threads/unique_future/cons/assign_neg.cc: Likewise.
+       * testsuite/30_threads/unique_future/cons/copy_neg.cc: Likewise.
+
+2009-12-15  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
        * include/std/functional (function::function): Move construct target.
        (function::operator=): Use perfect forwarding for argument.
        (function::operator()): Use new __throw_bad_function_call.
index b8c54b6..8f9975d 100644 (file)
@@ -42,6 +42,7 @@
 #include <system_error>
 #include <exception>
 #include <cstdatomic>
+#include <bits/functexcept.h>
 
 namespace std
 {
@@ -172,7 +173,7 @@ namespace std
        void
        _M_set(_Res&& __res)
        {
-         ::new (_M_addr()) _Res(_Move_result<_Res>::_S_move(__res));
+         ::new (_M_addr()) _Res(std::move(__res));
          _M_initialized = true;
        }
 
@@ -183,27 +184,6 @@ namespace std
     };
 
 
-    /// Workaround for CWG issue 664 and c++/34022
-    template<typename _Res, bool = is_scalar<_Res>::value>
-      struct _Move_result;
-
-     /// Specialization for scalar types returns rvalue not rvalue-reference.
-    template<typename _Res>
-      struct _Move_result<_Res, true>
-      {
-       typedef _Res __rval_type;
-       static _Res _S_move(_Res __res) { return __res; }
-      };
-    
-    /// Specialization for non-scalar types returns rvalue-reference.
-    template<typename _Res>
-      struct _Move_result<_Res, false>
-      {
-       typedef _Res&& __rval_type;
-       static _Res&& _S_move(_Res& __res) { return std::move(__res); }
-      };
-
-
     // TODO: use template alias when available
     /*
       template<typename _Res>
@@ -426,7 +406,6 @@ namespace std
 
       typedef __basic_future<_Res> _Base_type;
       typedef typename _Base_type::__state_type __state_type;
-      typedef __future_base::_Move_result<_Res> _Mover;
 
       explicit
       unique_future(const __state_type& __state) : _Base_type(__state) { }
@@ -440,9 +419,9 @@ namespace std
       unique_future& operator=(const unique_future&) = delete;
 
       /// Retrieving the value
-      typename _Mover::__rval_type
+      _Res&&
       get()
-      { return _Mover::_S_move(this->_M_get_result()._M_value()); }
+      { return std::move(this->_M_get_result()._M_value()); }
     };
  
   /// Partial specialization for unique_future<R&>
@@ -586,7 +565,6 @@ namespace std
       template<typename> friend class packaged_task;
 
       typedef __future_base::_State            _State;
-      typedef __future_base::_Move_result<_Res>        _Mover;
       typedef __future_base::_Result<_Res>     result_type;
       
       shared_ptr<_State>                        _M_future;
@@ -654,7 +632,7 @@ namespace std
       set_value(_Res&& __r)
       {
         if (!_M_satisfied())
-          _M_storage->_M_set(_Mover::_S_move(__r));
+          _M_storage->_M_set(std::move(__r));
         _M_future->_M_set_result(std::move(_M_storage));
       }
 
@@ -940,11 +918,9 @@ namespace std
         }
         __catch (const future_error& __e)
         {
-#ifdef __EXCEPTIONS
           if (__e.code() == future_errc::future_already_retrieved)
-           throw std::bad_function_call();
-         throw;
-#endif
+            __throw_bad_function_call();
+          __throw_exception_again;
         }
       }
 
@@ -953,13 +929,7 @@ namespace std
       operator()(_ArgTypes... __args)
       {
         if (!static_cast<bool>(_M_task) || _M_promise._M_satisfied())
-         {
-#ifdef __EXCEPTIONS
-           throw std::bad_function_call();
-#else
-           __builtin_abort();
-#endif
-         }
+          __throw_bad_function_call();
 
         __try
         {
index db3baf3..031ce0b 100644 (file)
@@ -33,4 +33,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 32 }
-// { dg-error "deleted function" "" { target *-*-* } 912 }
+// { dg-error "deleted function" "" { target *-*-* } 890 }
index 8e57d31..65cf9fd 100644 (file)
@@ -32,4 +32,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 31 }
-// { dg-error "deleted function" "" { target *-*-* } 911 }
+// { dg-error "deleted function" "" { target *-*-* } 889 }
index 5e16d14..5434740 100644 (file)
@@ -33,4 +33,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 32 }
-// { dg-error "deleted function" "" { target *-*-* } 630 }
+// { dg-error "deleted function" "" { target *-*-* } 608 }
index 1e85797..79d2e16 100644 (file)
@@ -32,4 +32,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 31 }
-// { dg-error "deleted function" "" { target *-*-* } 614 }
+// { dg-error "deleted function" "" { target *-*-* } 592 }
index 26211fe..0f284cd 100644 (file)
@@ -35,4 +35,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 34 }
-// { dg-error "deleted function" "" { target *-*-* } 514 }
+// { dg-error "deleted function" "" { target *-*-* } 493 }
index e29148e..69caf12 100644 (file)
@@ -35,4 +35,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 34 }
-// { dg-error "deleted function" "" { target *-*-* } 440 }
+// { dg-error "deleted function" "" { target *-*-* } 419 }
index 8134c7d..43e940c 100644 (file)
@@ -34,4 +34,4 @@ void test01()
 }
 
 // { dg-error "used here" "" { target *-*-* } 33 }
-// { dg-error "deleted function" "" { target *-*-* } 439 }
+// { dg-error "deleted function" "" { target *-*-* } 418 }