diff options
Diffstat (limited to 'test/std/thread')
26 files changed, 195 insertions, 113 deletions
diff --git a/test/std/thread/futures/futures.future_error/what.pass.cpp b/test/std/thread/futures/futures.future_error/what.pass.cpp index a44f8af7d41b4..cc2d978d2c2b4 100644 --- a/test/std/thread/futures/futures.future_error/what.pass.cpp +++ b/test/std/thread/futures/futures.future_error/what.pass.cpp @@ -12,8 +12,8 @@ // LWG 2056 changed the values of future_errc, so if we're using new headers // with an old library we'll get incorrect messages. // -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 -// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.7 +// XFAIL: with_system_cxx_lib=x86_64-apple-macosx10.8 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin13 // <future> diff --git a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp index e0c6e15d98d5e..e986885c0c713 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp @@ -6,7 +6,8 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// + +// UNSUPPORTED: c++98, c++03 // UNSUPPORTED: libcpp-has-no-threads, libcpp-no-exceptions // <future> @@ -19,8 +20,6 @@ #include <memory> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - struct A { A() {} @@ -28,11 +27,8 @@ struct A A(A&&) {throw 9;} }; -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unique_ptr<int> T; T i(new int(3)); @@ -65,5 +61,4 @@ int main() assert(j == 9); } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp index 8f3b76865e2a8..05675725bf437 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -19,23 +19,17 @@ #include <memory> #include <cassert> -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - void func(std::promise<std::unique_ptr<int>> p) { p.set_value_at_thread_exit(std::unique_ptr<int>(new int(5))); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::promise<std::unique_ptr<int>> p; std::future<std::unique_ptr<int>> f = p.get_future(); std::thread(func, std::move(p)).detach(); assert(*f.get() == 5); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp index 39784876b8c31..7cac21d48aefa 100644 --- a/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp +++ b/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp @@ -69,7 +69,7 @@ int main() p(3, 'a'); assert(f.get() == 105.0); assert(A::n_copies > 0); - assert(A::n_moves > 0); + assert(A::n_moves >= 0); } assert(test_alloc_base::alloc_count == 0); A::n_copies = 0; diff --git a/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp index 8d38b81f0cdad..4a790b06cfdfb 100644 --- a/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/move_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -20,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise<T> p; @@ -72,5 +71,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp index e12c920886fac..14e2eb4169614 100644 --- a/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/move_ctor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <future> @@ -20,7 +20,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise<T> p; @@ -66,5 +65,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.unique_future/share.pass.cpp b/test/std/thread/futures/futures.unique_future/share.pass.cpp index ef011d8df7529..9b8667e538cc2 100644 --- a/test/std/thread/futures/futures.unique_future/share.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/share.pass.cpp @@ -25,14 +25,16 @@ int main() typedef int T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } @@ -40,14 +42,16 @@ int main() typedef int& T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef int& T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } @@ -55,14 +59,16 @@ int main() typedef void T; std::promise<T> p; std::future<T> f0 = p.get_future(); - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(f.valid()); } { typedef void T; std::future<T> f0; - std::shared_future<T> f = std::move(f0.share()); + static_assert( noexcept(f0.share()), ""); + std::shared_future<T> f = f0.share(); assert(!f0.valid()); assert(!f.valid()); } diff --git a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp index d60e429188607..de225fe78384e 100644 --- a/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp +++ b/test/std/thread/thread.condition/PR30202_notify_from_pthread_created_thread.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// REQUIRES: libcpp-has-thread-api-pthread // notify_all_at_thread_exit(...) requires move semantics to transfer the // unique_lock. diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp index a2b7061c25467..71cbc94a70a42 100644 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp @@ -24,8 +24,8 @@ // ----------------------------------------------------------------------------- // Overview -// Check that std::terminate is called if wait(...) fails to meet it's post -// conditions. This can happens when reacquiring the mutex throws +// Check that std::terminate is called if wait(...) fails to meet its post +// conditions. This can happen when reacquiring the mutex throws // an exception. // // The following methods are tested within this file @@ -37,7 +37,7 @@ // 6. void wait_until(Lock& lock, TimePoint, Pred); // // Plan -// 1 Create a mutex type, 'ThrowingMutex', that throws when the lock is aquired +// 1 Create a mutex type, 'ThrowingMutex', that throws when the lock is acquired // for the *second* time. // // 2 Replace the terminate handler with one that exits with a '0' exit code. diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp index 46d04cdac350e..245c480885b83 100644 --- a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -9,10 +9,10 @@ // // UNSUPPORTED: libcpp-has-no-threads -// This test hangs forever when built against libstdc++. In order to allow +// This test hangs forever when built against libstdc++ and MSVC. In order to allow // validation of the test suite against other STLs we have to mark it // unsupported. -// UNSUPPORTED: libstdc++ +// UNSUPPORTED: libstdc++, msvc // <mutex> diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp index a15405fcd98b1..fffd087ee8776 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp @@ -15,11 +15,16 @@ // explicit lock_guard(mutex_type& m); +// template<class _Mutex> lock_guard(lock_guard<_Mutex>) +// -> lock_guard<_Mutex>; // C++17 + #include <mutex> #include <thread> #include <cstdlib> #include <cassert> +#include "test_macros.h" + std::mutex m; typedef std::chrono::system_clock Clock; @@ -47,4 +52,9 @@ int main() std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); + +#ifdef __cpp_deduction_guides + std::lock_guard lg(m); + static_assert((std::is_same<decltype(lg), std::lock_guard<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp index 81fc0d368f6a8..78165383a1585 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_adopt_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp @@ -8,18 +8,17 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard(Mutex&..., adopt_lock_t); +// scoped_lock(Mutex&..., adopt_lock_t); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> +#include "test_macros.h" struct TestMutex { bool locked = false; @@ -36,12 +35,22 @@ struct TestMutex { int main() { { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg(std::adopt_lock); } { + TestMutex m1; + using LG = std::scoped_lock<TestMutex>; + m1.lock(); + { + LG lg(m1, std::adopt_lock); + assert(m1.locked); + } + assert(!m1.locked); + } + { TestMutex m1, m2; - using LG = std::lock_guard<TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex>; m1.lock(); m2.lock(); { LG lg(m1, m2, std::adopt_lock); @@ -51,7 +60,7 @@ int main() } { TestMutex m1, m2, m3; - using LG = std::lock_guard<TestMutex, TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex, TestMutex>; m1.lock(); m2.lock(); m3.lock(); { LG lg(m1, m2, m3, std::adopt_lock); diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp index 1b4c9d4bfd5d6..a054729355269 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_assign.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/assign.fail.cpp @@ -8,17 +8,16 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard& operator=(lock_guard const&) = delete; +// scoped_lock& operator=(scoped_lock const&) = delete; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" int main() { @@ -26,18 +25,24 @@ int main() M m0, m1, m2; M om0, om1, om2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg1, lg2; lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + LG lg1(m0); + LG lg2(om0); + lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} + } + { + using LG = std::scoped_lock<M, M>; LG lg1(m0, m1); LG lg2(om0, om1); lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; LG lg1(m0, m1, m2); LG lg2(om0, om1, om2); lg1 = lg2; // expected-error{{overload resolution selected deleted operator '='}} diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp index c7fd0e94b771e..5075a42680952 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_copy.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/copy.fail.cpp @@ -8,34 +8,38 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// lock_guard(lock_guard const&) = delete; +// scoped_lock(scoped_lock const&) = delete; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" int main() { using M = std::mutex; M m0, m1, m2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; const LG Orig; LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + const LG Orig(m0); + LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} + } + { + using LG = std::scoped_lock<M, M>; const LG Orig(m0, m1); LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; const LG Orig(m0, m1, m2); LG Copy(Orig); // expected-error{{call to deleted constructor of 'LG'}} } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp index 1eef7e268fb25..7bb4673265cf1 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.fail.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.fail.cpp @@ -8,17 +8,16 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// explicit lock_guard(Mutex&...); +// explicit scoped_lock(Mutex&...); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> +#include "test_macros.h" template <class LG> void test_conversion(LG) {} @@ -29,19 +28,25 @@ int main() M m0, m1, m2; M n0, n1, n2; { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg = {}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({}); // expected-error{{no matching function for call}} ((void)lg); } { - using LG = std::lock_guard<M, M>; + using LG = std::scoped_lock<M>; + LG lg = {m0}; // expected-error{{chosen constructor is explicit in copy-initialization}} + test_conversion<LG>({n0}); // expected-error{{no matching function for call}} + ((void)lg); + } + { + using LG = std::scoped_lock<M, M>; LG lg = {m0, m1}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({n0, n1}); // expected-error{{no matching function for call}} ((void)lg); } { - using LG = std::lock_guard<M, M, M>; + using LG = std::scoped_lock<M, M, M>; LG lg = {m0, m1, m2}; // expected-error{{chosen constructor is explicit in copy-initialization}} test_conversion<LG>({n0, n1, n2}); // expected-error{{no matching function for call}} } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp index 8d83ddf98c6db..ef39bbcc5e888 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp @@ -8,19 +8,16 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class ...Mutex> class lock_guard; +// template <class ...Mutex> class scoped_lock; -// explicit lock_guard(mutex_type& m); +// explicit scoped_lock(mutex_type& m); -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <cassert> - #include "test_macros.h" struct TestMutex { @@ -68,11 +65,20 @@ struct TestMutexThrows { int main() { { - using LG = std::lock_guard<>; + using LG = std::scoped_lock<>; LG lg; } { - using LG = std::lock_guard<TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex>; + TestMutex m1; + { + LG lg(m1); + assert(m1.locked); + } + assert(!m1.locked); + } + { + using LG = std::scoped_lock<TestMutex, TestMutex>; TestMutex m1, m2; { LG lg(m1, m2); @@ -81,7 +87,7 @@ int main() assert(!m1.locked && !m2.locked); } { - using LG = std::lock_guard<TestMutex, TestMutex, TestMutex>; + using LG = std::scoped_lock<TestMutex, TestMutex, TestMutex>; TestMutex m1, m2, m3; { LG lg(m1, m2, m3); @@ -92,7 +98,18 @@ int main() #if !defined(TEST_HAS_NO_EXCEPTIONS) { using MT = TestMutexThrows; - using LG = std::lock_guard<MT, MT>; + using LG = std::scoped_lock<MT>; + MT m1; + m1.throws_on_lock = true; + try { + LG lg(m1); + assert(false); + } catch (int) {} + assert(!m1.locked); + } + { + using MT = TestMutexThrows; + using LG = std::scoped_lock<MT, MT>; MT m1, m2; m1.throws_on_lock = true; try { @@ -103,7 +120,7 @@ int main() } { using MT = TestMutexThrows; - using LG = std::lock_guard<MT, MT, MT>; + using LG = std::scoped_lock<MT, MT, MT>; MT m1, m2, m3; m2.throws_on_lock = true; try { @@ -113,4 +130,26 @@ int main() assert(!m1.locked && !m2.locked && !m3.locked); } #endif + +#ifdef __cpp_deduction_guides + { + TestMutex m1, m2, m3; + { + std::scoped_lock sl{}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<>>::value), "" ); + } + { + std::scoped_lock sl{m1}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1)>>::value), "" ); + } + { + std::scoped_lock sl{m1, m2}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1), decltype(m2)>>::value), "" ); + } + { + std::scoped_lock sl{m1, m2, m3}; + static_assert((std::is_same<decltype(sl), std::scoped_lock<decltype(m1), decltype(m2), decltype(m3)>>::value), "" ); + } + } +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp index 600399d9793e1..6af3c6c952d77 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_types.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/types.pass.cpp @@ -8,22 +8,21 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// UNSUPPORTED: c++98, c++03 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <mutex> -// template <class Mutex> -// class lock_guard +// template <class Mutex...> +// class scoped_lock // { // public: -// typedef Mutex mutex_type; +// typedef Mutex mutex_type; // only if sizeof...(Mutex) == 1 // ... // }; -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD #include <mutex> #include <type_traits> +#include "test_macros.h" struct NAT {}; @@ -41,39 +40,39 @@ constexpr bool has_mutex_type() { int main() { { - using T = std::lock_guard<>; + using T = std::scoped_lock<>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; - using T = std::lock_guard<M1>; + using T = std::scoped_lock<M1>; static_assert(std::is_same<T::mutex_type, M1>::value, ""); } { using M1 = std::recursive_mutex; - using T = std::lock_guard<M1>; + using T = std::scoped_lock<M1>; static_assert(std::is_same<T::mutex_type, M1>::value, ""); } { using M1 = std::mutex; using M2 = std::recursive_mutex; - using T = std::lock_guard<M1, M2>; + using T = std::scoped_lock<M1, M2>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; using M2 = std::recursive_mutex; - using T = std::lock_guard<M1, M1, M2>; + using T = std::scoped_lock<M1, M1, M2>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::mutex; - using T = std::lock_guard<M1, M1>; + using T = std::scoped_lock<M1, M1>; static_assert(!has_mutex_type<T>(), ""); } { using M1 = std::recursive_mutex; - using T = std::lock_guard<M1, M1, M1>; + using T = std::scoped_lock<M1, M1, M1>; static_assert(!has_mutex_type<T>(), ""); } } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp index f9a537085c30e..ac338064d1fd9 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp @@ -18,6 +18,9 @@ // explicit shared_lock(mutex_type& m); +// template<class _Mutex> shared_lock(shared_lock<_Mutex>) +// -> shared_lock<_Mutex>; // C++17 + #include <shared_mutex> #include <thread> #include <vector> @@ -92,4 +95,9 @@ int main() t.join(); q.join(); } + +#ifdef __cpp_deduction_guides + std::shared_lock sl(m); + static_assert((std::is_same<decltype(sl), std::shared_lock<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp index e5db685e46e75..6f17383298fd1 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <mutex> @@ -21,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::mutex M; M m0; @@ -46,5 +45,4 @@ int main() assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp index 427deabc5a59d..04aa796734312 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <mutex> @@ -21,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::mutex M; M m; @@ -42,5 +41,4 @@ int main() assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp index 1f7217a8300e1..ca8bc69822531 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp @@ -15,11 +15,16 @@ // explicit unique_lock(mutex_type& m); +// template<class _Mutex> unique_lock(unique_lock<_Mutex>) +// -> unique_lock<_Mutex>; // C++17 + #include <mutex> #include <thread> #include <cstdlib> #include <cassert> +#include "test_macros.h" + std::mutex m; typedef std::chrono::system_clock Clock; @@ -47,4 +52,9 @@ int main() std::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); + +#ifdef __cpp_deduction_guides + std::unique_lock ul(m); + static_assert((std::is_same<decltype(ul), std::unique_lock<decltype(m)>>::value), "" ); +#endif } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp index 2db9430a698d9..d3478818c0562 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <thread> @@ -44,7 +44,6 @@ bool G::op_run = false; int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { assert(G::n_alive == 0); assert(!G::op_run); @@ -61,5 +60,4 @@ int main() assert(G::n_alive == 0); assert(G::op_run); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp index 437b420379135..d419b8cc855c9 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp @@ -106,7 +106,7 @@ public: // A Each allocation performed during thread construction should be performed // in the parent thread so that std::terminate is not called if // std::bad_alloc is thrown by new. -// B std::threads constructor should properly handle exceptions and not leak +// B std::thread's constructor should properly handle exceptions and not leak // memory. // Plan: // 1 Create a thread and count the number of allocations, 'N', it performs. diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp index e88304ec8da9d..f349e4c56fcb9 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03 // <thread> @@ -53,7 +53,6 @@ bool G::op_run = false; int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { G g; assert(G::n_alive == 1); @@ -68,5 +67,4 @@ int main() assert(G::op_run); } assert(G::n_alive == 0); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp index 0ad16e2856fd8..9799467c4529f 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/variadic_mutex_cxx03.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/enabled_hashes.pass.cpp @@ -6,16 +6,22 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// + // UNSUPPORTED: libcpp-has-no-threads -// <mutex> +// UNSUPPORTED: c++98, c++03 + +// <thread> + +// Test that <thread> provides all of the arithmetic, enum, and pointer +// hash specializations. -// template <class ...Mutex> class lock_guard; +#include <thread> -// Test that the variadic lock guard implementation compiles in all standard -// dialects, including C++03, even though it is forward declared using -// variadic templates. +#include "poisoned_hash_helper.hpp" -// MODULES_DEFINES: _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD -#include "mutex.pass.cpp" // Use the existing non-variadic test +int main() { + test_library_hash_specializations_available(); + { + test_hash_enabled_for_type<std::thread::id>(); + } +} diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp index 106c69e2e4a1f..4f1491decd318 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp @@ -9,7 +9,7 @@ // // UNSUPPORTED: libcpp-has-no-threads -// <functional> +// <thread> // template <class T> // struct hash @@ -23,6 +23,8 @@ #include <thread> #include <cassert> +#include "test_macros.h" + int main() { std::thread::id id1; @@ -30,6 +32,7 @@ int main() typedef std::hash<std::thread::id> H; static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" ); static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); + ASSERT_NOEXCEPT(H()(id2)); H h; assert(h(id1) != h(id2)); } |