[gcc r15-5427] testsuite: move dg-test cleanup code from gcc-dg.exp to its own file

2024-11-18 Thread David Malcolm via Libstdc++-cvs
https://gcc.gnu.org/g:c9d21e19df2836b70365efbf759027b0f86a9b93

commit r15-5427-gc9d21e19df2836b70365efbf759027b0f86a9b93
Author: David Malcolm 
Date:   Mon Nov 18 16:49:04 2024 -0500

testsuite: move dg-test cleanup code from gcc-dg.exp to its own file

I need to use this cleanup logic for the testsuite for libdiagnostics
where it's too awkward to directly use gcc-dg.exp itself.

No functional change intended.

gcc/testsuite/ChangeLog:
* lib/dg-test-cleanup.exp: New file, from material moved from
lib/gcc-dg.exp.
* lib/gcc-dg.exp: Add load_lib of dg-test-cleanup.exp.
(cleanup-after-saved-dg-test): Move to lib/dg-test-cleanup.exp.
(dg-test): Likewise for override.
(initialize_prune_notes): Likewise.

libatomic/ChangeLog:
* testsuite/lib/libatomic.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libgomp/ChangeLog:
* testsuite/lib/libgomp.exp: Add
"load_gcc_lib dg-test-cleanup.exp".
libitm/ChangeLog:
* testsuite/lib/libitm.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libphobos/ChangeLog:
* testsuite/lib/libphobos-dg.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libstdc++-v3/ChangeLog:
* testsuite/lib/libstdc++.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

libvtv/ChangeLog:
* testsuite/lib/libvtv.exp: Add
"load_gcc_lib dg-test-cleanup.exp".

Signed-off-by: David Malcolm 

Diff:
---
 gcc/testsuite/lib/dg-test-cleanup.exp| 116 +++
 gcc/testsuite/lib/gcc-dg.exp | 102 +--
 libatomic/testsuite/lib/libatomic.exp|   1 +
 libgomp/testsuite/lib/libgomp.exp|   1 +
 libitm/testsuite/lib/libitm.exp  |   1 +
 libphobos/testsuite/lib/libphobos-dg.exp |   1 +
 libstdc++-v3/testsuite/lib/libstdc++.exp |   1 +
 libvtv/testsuite/lib/libvtv.exp  |   1 +
 8 files changed, 123 insertions(+), 101 deletions(-)

diff --git a/gcc/testsuite/lib/dg-test-cleanup.exp 
b/gcc/testsuite/lib/dg-test-cleanup.exp
new file mode 100644
index ..b2b8507a0320
--- /dev/null
+++ b/gcc/testsuite/lib/dg-test-cleanup.exp
@@ -0,0 +1,116 @@
+#   Copyright (C) 1997-2024 Free Software Foundation, Inc.
+
+# This program 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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 GCC; see the file COPYING3.  If not see
+# .
+
+# We need to make sure that additional_* are cleared out after every
+# test.  It is not enough to clear them out *before* the next test run
+# because gcc-target-compile gets run directly from some .exp files
+# (outside of any test).  (Those uses should eventually be eliminated.)
+
+# Because the DG framework doesn't provide a hook that is run at the
+# end of a test, we must replace dg-test with a wrapper.
+
+if { [info procs saved-dg-test] == [list] } {
+rename dg-test saved-dg-test
+
+# Helper function for cleanups that should happen after the call
+# to the real dg-test, whether or not it returns normally, or
+# fails with an error.
+proc cleanup-after-saved-dg-test { } {
+   global additional_files
+   global additional_sources
+   global additional_sources_used
+   global additional_prunes
+   global compiler_conditional_xfail_data
+   global shouldfail
+   global expect_ice
+   global testname_with_flags
+   global set_target_env_var
+   global set_compiler_env_var
+   global saved_compiler_env_var
+   global keep_saved_temps_suffixes
+   global nn_line_numbers_enabled
+   global multiline_expected_outputs
+   global freeform_regexps
+   global save_linenr_varnames
+
+   set additional_files ""
+   set additional_sources ""
+   set additional_sources_used ""
+   set additional_prunes ""
+   set shouldfail 0
+   set expect_ice 0
+   if [info exists set_target_env_var] {
+   unset set_target_env_var
+   }
+   if [info exists set_compiler_env_var] {
+   restore-compiler-env-var
+   unset set_compiler_env_var
+   unset saved_compiler_env_var
+   }
+   if [info exists keep_saved_temps_suffixes] {
+   unset keep_saved_temps_suffixes
+   }
+   unset_timeout_vars
+   if [info exists compiler_conditional_xfail_data] {
+   un

[gcc r15-8994] libstdc++-v3 testsuite: fix malformed dg-require-static-libstdcxx directives

2025-03-27 Thread David Malcolm via Libstdc++-cvs
https://gcc.gnu.org/g:1ee9caf2f84832f9eefef4953758e26ab505173c

commit r15-8994-g1ee9caf2f84832f9eefef4953758e26ab505173c
Author: David Malcolm 
Date:   Thu Mar 27 20:00:34 2025 -0400

libstdc++-v3 testsuite: fix malformed dg-require-static-libstdcxx directives

I believe these don't get detected by DejaGnu's regexp.

Found by dg-lint.

libstdc++-v3/ChangeLog:
* testsuite/17_intro/shared_with_static_deps.cc: Fix malformed
dg-require-static-libstdcxx directive.
* testsuite/17_intro/static.cc: Likewise.
* testsuite/18_support/type_info/110572.cc: Likewise.
* testsuite/20_util/to_chars/4.cc: Likewise.
* testsuite/std/time/tzdb_list/pr118811.cc: Likewise.

Signed-off-by: David Malcolm 

Diff:
---
 libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc | 2 +-
 libstdc++-v3/testsuite/17_intro/static.cc  | 2 +-
 libstdc++-v3/testsuite/18_support/type_info/110572.cc  | 2 +-
 libstdc++-v3/testsuite/20_util/to_chars/4.cc   | 2 +-
 libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc  | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc 
b/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc
index 9491bbcd5741..a84c110ab52c 100644
--- a/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc
+++ b/libstdc++-v3/testsuite/17_intro/shared_with_static_deps.cc
@@ -1,5 +1,5 @@
 // { dg-do link }
-// { dg-require-static-libstdcxx }
+// { dg-require-static-libstdcxx "" }
 // { dg-require-sharedlib "" }
 // { dg-require-effective-target fpic }
 // { dg-options "-shared -fPIC -static-libgcc -static-libstdc++" }
diff --git a/libstdc++-v3/testsuite/17_intro/static.cc 
b/libstdc++-v3/testsuite/17_intro/static.cc
index ab0cf279d994..26b34c819d52 100644
--- a/libstdc++-v3/testsuite/17_intro/static.cc
+++ b/libstdc++-v3/testsuite/17_intro/static.cc
@@ -1,5 +1,5 @@
 // { dg-do run { target c++11 } }
-// { dg-require-static-libstdcxx }
+// { dg-require-static-libstdcxx "" }
 // { dg-options "-static-libstdc++" }
 
 // Copyright (C) 2012-2025 Free Software Foundation, Inc.
diff --git a/libstdc++-v3/testsuite/18_support/type_info/110572.cc 
b/libstdc++-v3/testsuite/18_support/type_info/110572.cc
index f727653adfb1..5a05078510fe 100644
--- a/libstdc++-v3/testsuite/18_support/type_info/110572.cc
+++ b/libstdc++-v3/testsuite/18_support/type_info/110572.cc
@@ -1,6 +1,6 @@
 // { dg-options "-static-libstdc++" }
 // { dg-do link }
-// { dg-require-static-libstdcxx }
+// { dg-require-static-libstdcxx "" }
 // { dg-require-cpp-feature-test __cpp_rtti }
 
 #include 
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/4.cc 
b/libstdc++-v3/testsuite/20_util/to_chars/4.cc
index 3d76d5691287..65abfaaff952 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/4.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/4.cc
@@ -17,7 +17,7 @@
 
 // { dg-do link { target c++17 } }
 // { dg-require-effective-target ieee_floats }
-// { dg-require-static-libstdcxx }
+// { dg-require-static-libstdcxx "" }
 // { dg-additional-options "-static-libstdc++" }
 
 // Verify the Ryu symbol generic_to_chars doesn't inadvertently leak into
diff --git a/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc 
b/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc
index 3968be3f0eca..fe86602ecce9 100644
--- a/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc
+++ b/libstdc++-v3/testsuite/std/time/tzdb_list/pr118811.cc
@@ -1,7 +1,7 @@
 // { dg-do run { target c++20 } }
 // { dg-require-effective-target tzdb }
 // { dg-require-effective-target cxx11_abi }
-// { dg-require-static-libstdcxx }
+// { dg-require-static-libstdcxx "" }
 // { dg-additional-options "-static-libstdc++" }
 
 #include