diff options
Diffstat (limited to 'libstdc++-v3/testsuite')
10 files changed, 75 insertions, 13 deletions
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/pr118757.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/pr118757.cc index d54abd8..f49ae38 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/pr118757.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/pr118757.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++20 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } // { dg-require-effective-target hosted } diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/pr118757.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/pr118757.cc index f048f13..77757f3 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/pr118757.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/pr118757.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++20 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } // { dg-require-effective-target hosted } diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/108951.cc b/libstdc++-v3/testsuite/26_numerics/valarray/108951.cc new file mode 100644 index 0000000..929a1d4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/108951.cc @@ -0,0 +1,22 @@ +// { dg-do run { target c++11 } } +// { dg-additional-options "-faligned-new" { target c++14_down } } + +#include <valarray> +#include <cstdint> +#include <testsuite_hooks.h> + +struct alignas(64) Num +{ + Num() + { + VERIFY(reinterpret_cast<std::uintptr_t>(this) % alignof(*this) == 0); + } + + double val{}; +}; + +int main() +{ + std::valarray<Num> v(2); + v.resize(4, {}); +} diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc b/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc index 7114007..e8c3e16 100644 --- a/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc +++ b/libstdc++-v3/testsuite/30_threads/condition_variable/members/116586.cc @@ -1,4 +1,7 @@ // { dg-do run { target c++11 } } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-require-gthreads "" } +// { dg-require-effective-target hosted } #include <condition_variable> #include <chrono> diff --git a/libstdc++-v3/testsuite/30_threads/future/members/116586.cc b/libstdc++-v3/testsuite/30_threads/future/members/116586.cc index b7cd12c..82f1e5c 100644 --- a/libstdc++-v3/testsuite/30_threads/future/members/116586.cc +++ b/libstdc++-v3/testsuite/30_threads/future/members/116586.cc @@ -1,4 +1,7 @@ // { dg-do run { target c++11 } } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-require-gthreads "" } +// { dg-require-effective-target hosted } #include <future> #include <chrono> diff --git a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc index 941f3af..25a78e7 100644 --- a/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc +++ b/libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/116586.cc @@ -1,4 +1,7 @@ // { dg-do run { target c++11 } } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-require-gthreads "" } +// { dg-require-effective-target hosted } #include <mutex> #include <chrono> diff --git a/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc b/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc index cebbb3a..5736b7d 100644 --- a/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc +++ b/libstdc++-v3/testsuite/30_threads/shared_timed_mutex/try_lock_until/116586.cc @@ -1,4 +1,7 @@ // { dg-do run { target c++14 } } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-require-gthreads "" } +// { dg-require-effective-target hosted } #include <shared_mutex> #include <chrono> @@ -8,10 +11,18 @@ namespace chrono = std::chrono; -// thread.timedmutex.requirements.general: +// [thread.timedmutex.requirements.general]: // If abs_time has already passed, the function attempts to obtain // ownership without blocking (as if by calling try_lock()). +// C++14 [thread.sharedtimedmutex.class] 3.2 says it's undefined for a thread +// to attempt to recursively gain any ownership of a shared_timed_mutex. +// This isn't just theoretical, as Glibc's pthread_rwlock_timedrdlock will +// return EDEADLK if called on the same thread that already holds the +// exclusive (write) lock. +#define VERIFY_IN_NEW_THREAD(X) \ + (void) std::async(std::launch::async, [&] { VERIFY(X); }) + template <typename Clock> void test_exclusive_absolute(chrono::nanoseconds offset) @@ -19,7 +30,7 @@ test_exclusive_absolute(chrono::nanoseconds offset) std::shared_timed_mutex stm; chrono::time_point<Clock> tp(offset); VERIFY(stm.try_lock_until(tp)); - VERIFY(!stm.try_lock_until(tp)); + VERIFY_IN_NEW_THREAD(!stm.try_lock_until(tp)); } template <typename Clock> @@ -32,15 +43,7 @@ test_shared_absolute(chrono::nanoseconds offset) stm.unlock_shared(); VERIFY(stm.try_lock_for(chrono::seconds{10})); - - { - // NPTL will give us EDEADLK if pthread_rwlock_timedrdlock() is called on - // the same thread that already holds the exclusive (write) lock, so let's - // arrange for a different thread to try to acquire the shared lock. - auto t = std::async(std::launch::async, [&stm, tp]() { - VERIFY(!stm.try_lock_shared_until(tp)); - }); - } + VERIFY_IN_NEW_THREAD(!stm.try_lock_shared_until(tp)); } // The type of clock used for the actual wait depends on whether @@ -53,7 +56,7 @@ test_exclusive_relative(chrono::nanoseconds offset) std::shared_timed_mutex stm; const auto d = -Clock::now().time_since_epoch() + offset; VERIFY(stm.try_lock_for(d)); - VERIFY(!stm.try_lock_for(d)); + VERIFY_IN_NEW_THREAD(!stm.try_lock_for(d)); } template <typename Clock> @@ -66,7 +69,7 @@ test_shared_relative(chrono::nanoseconds offset) stm.unlock_shared(); // Should complete immediately VERIFY(stm.try_lock_for(chrono::seconds{10})); - VERIFY(!stm.try_lock_shared_for(d)); + VERIFY_IN_NEW_THREAD(!stm.try_lock_shared_for(d)); } int main() diff --git a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc index dcba7aa..1566228 100644 --- a/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc +++ b/libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/116586.cc @@ -1,4 +1,7 @@ // { dg-do run { target c++11 } } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-require-gthreads "" } +// { dg-require-effective-target hosted } #include <chrono> #include <mutex> diff --git a/libstdc++-v3/testsuite/ext/iotaarray.cc b/libstdc++-v3/testsuite/ext/iotaarray.cc new file mode 100644 index 0000000..b259602 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/iotaarray.cc @@ -0,0 +1,20 @@ +// { dg-do compile { target c++26 } } + +#include <utility> +#include <type_traits> + +template<auto N> +void test() +{ + constexpr auto [id0, ...ids] = std::_IotaArray<N>; + static_assert( std::is_same_v<decltype(id0), const decltype(N)> ); + static_assert( sizeof...(ids) == N - 1 ); + static_assert( (id0 + ... + ids) == N*(N-1)/2 ); +} + +int main() +{ + test<1>(); + test<4u>(); + test<8ull>(); +} diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 5bf2e70..41fbcaa 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -674,6 +674,9 @@ namespace __gnu_test template <class T, template<class TT> class ItType> struct test_container { + typedef ItType<T> iterator; + typedef typename iterator::value_type value_type; + typename ItType<T>::ContainerType bounds; _GLIBCXX_CONSTEXPR |
