From 8cd5e57b251ba4af2ff301e92564dbf8d746632c Mon Sep 17 00:00:00 2001 From: Jonathan Wakely <jwakely@redhat.com> Date: Thu, 7 Sep 2023 13:56:15 +0100 Subject: [PATCH] libstdc++: Simplify dejagnu directives for some tests using threads Replace dg-require-effective-target directives with a target selector on the dg-do directive. We can also remove { dg-require-effective-target pthread } and the associated { dg-options "-pthread" } by allowing it to run on non-pthread targets and conditionally adding -pthread only for pthread targets. libstdc++-v3/ChangeLog: * testsuite/20_util/shared_ptr/atomic/3.cc: Simplify dg directives. * testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc: Likewise. * testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/allocate.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/allocate_single.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/cons.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/cons_single.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/is_equal.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/multithreaded.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/options.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/release.cc: Likewise. * testsuite/20_util/synchronized_pool_resource/release_single.cc: Likewise. * testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc: Likewise. * testsuite/30_threads/stop_token/stop_callback/deadlock-mt.cc: Likewise. * testsuite/30_threads/stop_token/stop_callback/destroy.cc: Likewise. --- libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc | 3 +-- .../20_util/shared_ptr/thread/default_weaktoshared.cc | 3 +-- .../20_util/shared_ptr/thread/mutex_weaktoshared.cc | 3 +-- .../20_util/synchronized_pool_resource/allocate.cc | 6 ++---- .../20_util/synchronized_pool_resource/allocate_single.cc | 3 +-- .../testsuite/20_util/synchronized_pool_resource/cons.cc | 6 ++---- .../20_util/synchronized_pool_resource/cons_single.cc | 3 +-- .../20_util/synchronized_pool_resource/is_equal.cc | 6 ++---- .../20_util/synchronized_pool_resource/multithreaded.cc | 6 ++---- .../testsuite/20_util/synchronized_pool_resource/options.cc | 6 ++---- .../testsuite/20_util/synchronized_pool_resource/release.cc | 6 ++---- .../20_util/synchronized_pool_resource/release_single.cc | 3 +-- .../30_threads/condition_variable_any/stop_token/wait_on.cc | 6 ++---- .../30_threads/stop_token/stop_callback/deadlock-mt.cc | 5 ++--- .../30_threads/stop_token/stop_callback/destroy.cc | 5 ++--- 15 files changed, 24 insertions(+), 46 deletions(-) diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc index 8346191412c0..19efcadb7ec4 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/atomic/3.cc @@ -1,6 +1,5 @@ -// { dg-do run } +// { dg-do run { target c++11 } } // { dg-additional-options "-pthread" { target pthread } } -// { dg-require-effective-target c++11 } // { dg-require-gthreads "" } // Copyright (C) 2014-2023 Free Software Foundation, Inc. diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc index 20c910c2fcd9..af0e65e9469c 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc @@ -17,10 +17,9 @@ // 20.6.6.2 Template class shared_ptr [util.smartptr.shared] -// { dg-do run } +// { dg-do run { target c++11 } } // { dg-additional-options "-pthread" { target pthread } } // { dg-add-options libatomic } -// { dg-require-effective-target c++11 } // { dg-require-gthreads "" } // { dg-require-cstdint "" } diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc index d6c8611aa85b..07f7c49bf100 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc @@ -17,10 +17,9 @@ // 20.6.6.2 Template class shared_ptr [util.smartptr.shared] -// { dg-do run } +// { dg-do run { target c++11 } } // { dg-additional-options "-pthread" { target pthread } } // { dg-add-options libatomic } -// { dg-require-effective-target c++11 } // { dg-require-gthreads "" } // { dg-require-cstdint "" } diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate.cc index f9a4a2f36946..822a410b6c2a 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate.cc @@ -15,10 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-options "-pthread" } -// { dg-require-effective-target c++17 } -// { dg-require-effective-target pthread } +// { dg-do run { target c++17 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <memory_resource> diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate_single.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate_single.cc index a29575fdd80e..4acfde6e9d7b 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate_single.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/allocate_single.cc @@ -15,8 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-require-effective-target c++17 } +// { dg-do run { target c++17 } } // { dg-require-gthreads "" } // This runs the same tests as allocate.cc but without -pthread diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons.cc index f8b74d9d8cc4..a3f98586684a 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons.cc @@ -15,10 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-options "-pthread" } -// { dg-require-effective-target c++17 } -// { dg-require-effective-target pthread } +// { dg-do run { target c++17 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <memory_resource> diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons_single.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons_single.cc index ab215ba3c935..9668a51c346b 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons_single.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/cons_single.cc @@ -15,8 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-require-effective-target c++17 } +// { dg-do run { target c++17 } } // { dg-require-gthreads "" } // This runs the same tests as cons.cc but without -pthread diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/is_equal.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/is_equal.cc index 5be6bd696639..aacf00b079cd 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/is_equal.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/is_equal.cc @@ -15,10 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-options "-pthread" } -// { dg-require-effective-target c++17 } -// { dg-require-effective-target pthread } +// { dg-do run { target c++17 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <memory_resource> diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/multithreaded.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/multithreaded.cc index a7283bf54053..7992367ffdaa 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/multithreaded.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/multithreaded.cc @@ -15,10 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-options "-pthread" } -// { dg-require-effective-target c++17 } -// { dg-require-effective-target pthread } +// { dg-do run { target c++17 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <memory_resource> diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/options.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/options.cc index a869b993ee30..9d98b5038db9 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/options.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/options.cc @@ -15,10 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-options "-pthread" } -// { dg-require-effective-target c++17 } -// { dg-require-effective-target pthread } +// { dg-do run { target c++17 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <memory_resource> diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release.cc index d1c60432dd71..6752d6e270c9 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release.cc @@ -15,10 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-options "-pthread" } -// { dg-require-effective-target c++17 } -// { dg-require-effective-target pthread } +// { dg-do run { target c++17 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <memory_resource> diff --git a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release_single.cc b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release_single.cc index f69e96034ad2..9645bc64c02c 100644 --- a/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release_single.cc +++ b/libstdc++-v3/testsuite/20_util/synchronized_pool_resource/release_single.cc @@ -15,8 +15,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do run } -// { dg-require-effective-target c++17 } +// { dg-do run { target c++17 } } // { dg-require-gthreads "" } // This runs the same tests as release.cc but without -pthread diff --git a/libstdc++-v3/testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc b/libstdc++-v3/testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc index edebaa6acaba..bac1f3509b51 100644 --- a/libstdc++-v3/testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc +++ b/libstdc++-v3/testsuite/30_threads/condition_variable_any/stop_token/wait_on.cc @@ -15,11 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-options "-std=gnu++2a -pthread" } // { dg-add-options libatomic } -// { dg-do run } -// { dg-require-effective-target c++2a } -// { dg-require-effective-target pthread } +// { dg-do run { target c++20 } } +// { dg-additional-options "-pthread" { target pthread } } #include <condition_variable> #include <thread> diff --git a/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/deadlock-mt.cc b/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/deadlock-mt.cc index f6162879e544..e780955dbecf 100644 --- a/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/deadlock-mt.cc +++ b/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/deadlock-mt.cc @@ -15,10 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-options "-std=gnu++2a -pthread" } // { dg-add-options libatomic } -// { dg-require-effective-target c++2a } -// { dg-require-effective-target pthread } +// { dg-do run { target c++20 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <stop_token> diff --git a/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc b/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc index 6bdd4d13f54f..f13761ca0fe7 100644 --- a/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc +++ b/libstdc++-v3/testsuite/30_threads/stop_token/stop_callback/destroy.cc @@ -15,10 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-options "-std=gnu++2a -pthread" } // { dg-add-options libatomic } -// { dg-require-effective-target c++2a } -// { dg-require-effective-target pthread } +// { dg-do run { target c++20 } } +// { dg-additional-options "-pthread" { target pthread } } // { dg-require-gthreads "" } #include <stop_token> -- GitLab