| 1 |
# Copyright (C) 1997-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with GCC; see the file COPYING3. If not see |
| 15 |
# <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
# We need to make sure that additional_* are cleared out after every |
| 18 |
# test. It is not enough to clear them out *before* the next test run |
| 19 |
# because gcc-target-compile gets run directly from some .exp files |
| 20 |
# (outside of any test). (Those uses should eventually be eliminated.) |
| 21 |
|
| 22 |
# Because the DG framework doesn't provide a hook that is run at the |
| 23 |
# end of a test, we must replace dg-test with a wrapper. |
| 24 |
|
| 25 |
if { [info procs saved-dg-test] == [list] } { |
| 26 |
rename dg-test saved-dg-test |
| 27 |
|
| 28 |
# Helper function for cleanups that should happen after the call |
| 29 |
# to the real dg-test, whether or not it returns normally, or |
| 30 |
# fails with an error. |
| 31 |
proc cleanup-after-saved-dg-test { } { |
| 32 |
global additional_files |
| 33 |
global additional_sources |
| 34 |
global additional_sources_used |
| 35 |
global additional_prunes |
| 36 |
global compiler_conditional_xfail_data |
| 37 |
global shouldfail |
| 38 |
global expect_ice |
| 39 |
global testname_with_flags |
| 40 |
global set_target_env_var |
| 41 |
global set_compiler_env_var |
| 42 |
global saved_compiler_env_var |
| 43 |
global keep_saved_temps_suffixes |
| 44 |
global nn_line_numbers_enabled |
| 45 |
global multiline_expected_outputs |
| 46 |
global freeform_regexps |
| 47 |
global save_linenr_varnames |
| 48 |
global output-file |
| 49 |
|
| 50 |
set additional_files "" |
| 51 |
set additional_sources "" |
| 52 |
set additional_sources_used "" |
| 53 |
set additional_prunes "" |
| 54 |
set shouldfail 0 |
| 55 |
set expect_ice 0 |
| 56 |
if [info exists set_target_env_var] { |
| 57 |
unset set_target_env_var |
| 58 |
} |
| 59 |
if [info exists set_compiler_env_var] { |
| 60 |
restore-compiler-env-var |
| 61 |
unset set_compiler_env_var |
| 62 |
unset saved_compiler_env_var |
| 63 |
} |
| 64 |
if [info exists keep_saved_temps_suffixes] { |
| 65 |
unset keep_saved_temps_suffixes |
| 66 |
} |
| 67 |
unset_timeout_vars |
| 68 |
if [info exists compiler_conditional_xfail_data] { |
| 69 |
unset compiler_conditional_xfail_data |
| 70 |
} |
| 71 |
if [info exists testname_with_flags] { |
| 72 |
unset testname_with_flags |
| 73 |
} |
| 74 |
if [info exists output-file] { |
| 75 |
unset output-file |
| 76 |
} |
| 77 |
set nn_line_numbers_enabled 0 |
| 78 |
set multiline_expected_outputs [] |
| 79 |
set freeform_regexps [] |
| 80 |
|
| 81 |
if { [info exists save_linenr_varnames] } { |
| 82 |
foreach varname $save_linenr_varnames { |
| 83 |
# Cleanup varname |
| 84 |
eval global $varname |
| 85 |
eval unset $varname |
| 86 |
|
| 87 |
# Cleanup varname_used, or generate defined-but-not-used |
| 88 |
# warning. |
| 89 |
set varname_used used_$varname |
| 90 |
eval global $varname_used |
| 91 |
eval set used [info exists $varname_used] |
| 92 |
if { $used } { |
| 93 |
eval unset $varname_used |
| 94 |
} else { |
| 95 |
regsub {^saved_linenr_} $varname "" org_varname |
| 96 |
warning "dg-line var $org_varname defined, but not used" |
| 97 |
} |
| 98 |
} |
| 99 |
unset save_linenr_varnames |
| 100 |
} |
| 101 |
|
| 102 |
initialize_prune_notes |
| 103 |
} |
| 104 |
|
| 105 |
proc dg-test { args } { |
| 106 |
global errorInfo |
| 107 |
|
| 108 |
if { [ catch { eval saved-dg-test $args } errmsg ] } { |
| 109 |
set saved_info $errorInfo |
| 110 |
cleanup-after-saved-dg-test |
| 111 |
error $errmsg $saved_info |
| 112 |
} |
| 113 |
cleanup-after-saved-dg-test |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
proc initialize_prune_notes { } { |
| 118 |
global prune_notes |
| 119 |
set prune_notes 1 |
| 120 |
} |