Merged revisions 208012,208018-208019,208021,208023-208030,208033,208037,208040-20804...
[official-gcc.git] / main / gcc / testsuite / lib / gcc-dg.exp
blobf9d52bcf63d7e94280d83e5fb2ee2a2198fd1002
1 # Copyright (C) 1997-2014 Free Software Foundation, Inc.
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.
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.
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/>.
17 load_lib dg.exp
18 load_lib file-format.exp
19 load_lib target-supports.exp
20 load_lib target-supports-dg.exp
21 load_lib scanasm.exp
22 load_lib scanrtl.exp
23 load_lib scantree.exp
24 load_lib scanipa.exp
25 load_lib timeout.exp
26 load_lib timeout-dg.exp
27 load_lib prune.exp
28 load_lib libgloss.exp
29 load_lib target-libpath.exp
30 load_lib torture-options.exp
31 load_lib fortran-modules.exp
33 # We set LC_ALL and LANG to C so that we get the same error messages as expected.
34 setenv LC_ALL C
35 setenv LANG C
37 # Many hosts now default to a non-ASCII C locale, however, so
38 # they can set a charset encoding here if they need.
39 if { [ishost "*-*-cygwin*"] } {
40 setenv LC_ALL C.ASCII
41 setenv LANG C.ASCII
44 global GCC_UNDER_TEST
45 if ![info exists GCC_UNDER_TEST] {
46 set GCC_UNDER_TEST "[find_gcc]"
49 if [info exists TORTURE_OPTIONS] {
50 set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
51 } else {
52 # It is theoretically beneficial to group all of the O2/O3 options together,
53 # as in many cases the compiler will generate identical executables for
54 # all of them--and the c-torture testsuite will skip testing identical
55 # executables multiple times.
56 # Also note that -finline-functions is explicitly included in one of the
57 # items below, even though -O3 is also specified, because some ports may
58 # choose to disable inlining functions by default, even when optimizing.
59 set DG_TORTURE_OPTIONS [list \
60 { -O0 } \
61 { -O1 } \
62 { -O2 } \
63 { -O3 -fomit-frame-pointer } \
64 { -O3 -fomit-frame-pointer -funroll-loops } \
65 { -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
66 { -O3 -g } \
67 { -Os } ]
70 if [info exists ADDITIONAL_TORTURE_OPTIONS] {
71 set DG_TORTURE_OPTIONS \
72 [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
75 set LTO_TORTURE_OPTIONS ""
77 # Some torture-options cause intermediate code output, unusable for
78 # testing using e.g. scan-assembler. In this variable are the options
79 # how to force it, when needed.
80 global gcc_force_conventional_output
81 set gcc_force_conventional_output ""
83 if [check_effective_target_lto] {
84 # When having plugin test both slim and fat LTO and plugin/nonplugin
85 # path.
86 if [check_linker_plugin_available] {
87 set LTO_TORTURE_OPTIONS [list \
88 { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
89 { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
91 set gcc_force_conventional_output "-ffat-lto-objects"
92 } else {
93 set LTO_TORTURE_OPTIONS [list \
94 { -O2 -flto -flto-partition=none } \
95 { -O2 -flto }
100 global orig_environment_saved
102 # This file may be sourced, so don't override environment settings
103 # that have been previously setup.
104 if { $orig_environment_saved == 0 } {
105 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
106 set_ld_library_path_env_vars
109 # Define gcc callbacks for dg.exp.
111 proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
112 # Set up the compiler flags, based on what we're going to do.
114 set options [list]
116 # Tests should be able to use "dg-do repo". However, the dg test
117 # driver checks the argument to dg-do against a list of acceptable
118 # options, and "repo" is not among them. Therefore, we resort to
119 # this ugly approach.
120 if [string match "*-frepo*" $extra_tool_flags] then {
121 set do_what "repo"
124 switch $do_what {
125 "preprocess" {
126 set compile_type "preprocess"
127 set output_file "[file rootname [file tail $prog]].i"
129 "compile" {
130 set compile_type "assembly"
131 set output_file "[file rootname [file tail $prog]].s"
133 "assemble" {
134 set compile_type "object"
135 set output_file "[file rootname [file tail $prog]].o"
137 "precompile" {
138 set compile_type "precompiled_header"
139 set output_file "[file tail $prog].gch"
141 "link" {
142 set compile_type "executable"
143 set output_file "[file rootname [file tail $prog]].exe"
144 # The following line is needed for targets like the i960 where
145 # the default output file is b.out. Sigh.
147 "repo" {
148 set compile_type "object"
149 set output_file "[file rootname [file tail $prog]].o"
151 "run" {
152 set compile_type "executable"
153 # FIXME: "./" is to cope with "." not being in $PATH.
154 # Should this be handled elsewhere?
155 # YES.
156 set output_file "./[file rootname [file tail $prog]].exe"
157 # This is the only place where we care if an executable was
158 # created or not. If it was, dg.exp will try to run it.
159 catch { remote_file build delete $output_file }
161 default {
162 perror "$do_what: not a valid dg-do keyword"
163 return ""
167 # Let { dg-final { action } } force options as returned by an
168 # optional proc ${action}_required_options.
169 upvar 2 dg-final-code finalcode
170 foreach x [split $finalcode "\n"] {
171 set finalcmd [lindex $x 0]
172 if { [info procs ${finalcmd}_required_options] != "" } {
173 set req [${finalcmd}_required_options]
174 if { $req != "" } {
175 lappend extra_tool_flags $req
180 if { $extra_tool_flags != "" } {
181 lappend options "additional_flags=$extra_tool_flags"
184 set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]
186 # Look for an internal compiler error, which sometimes masks the fact
187 # that we didn't get an expected error message. XFAIL an ICE via
188 # dg-xfail-if and use { dg-prune-output ".*internal compiler error.*" }
189 # to avoid a second failure for excess errors.
190 if [string match "*internal compiler error*" $comp_output] {
191 upvar 2 name name
192 fail "$name (internal compiler error)"
195 if { $do_what == "repo" } {
196 set object_file "$output_file"
197 set output_file "[file rootname [file tail $prog]].exe"
198 set comp_output \
199 [ concat $comp_output \
200 [$target_compile "$object_file" "$output_file" \
201 "executable" $options] ]
204 return [list $comp_output $output_file]
207 proc gcc-dg-test { prog do_what extra_tool_flags } {
208 return [gcc-dg-test-1 gcc_target_compile $prog $do_what $extra_tool_flags]
211 proc gcc-dg-prune { system text } {
212 global additional_prunes
214 # Extra prune rules that will apply to tests defined in a .exp file.
215 # Always remember to clear it in .exp file after executed all tests.
216 global dg_runtest_extra_prunes
218 set text [prune_gcc_output $text]
220 foreach p "$additional_prunes $dg_runtest_extra_prunes" {
221 if { [string length $p] > 0 } {
222 # Following regexp matches a complete line containing $p.
223 regsub -all "(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text
227 # If we see "region xxx is full" then the testcase is too big for ram.
228 # This is tricky to deal with in a large testsuite like c-torture so
229 # deal with it here. Just mark the testcase as unsupported.
230 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $text] {
231 # The format here is important. See dg.exp.
232 return "::unsupported::memory full"
235 # Likewise, if we see ".text exceeds local store range" or
236 # similar.
237 if {[string match "spu-*" $system] && \
238 [string match "*exceeds local store*" $text]} {
239 # The format here is important. See dg.exp.
240 return "::unsupported::memory full"
243 return $text
246 # Replace ${tool}_load with a wrapper to provide for an expected nonzero
247 # exit status. Multiple languages include this file so this handles them
248 # all, not just gcc.
249 if { [info procs ${tool}_load] != [list] \
250 && [info procs saved_${tool}_load] == [list] } {
251 rename ${tool}_load saved_${tool}_load
253 proc ${tool}_load { program args } {
254 global tool
255 global shouldfail
256 global set_target_env_var
258 set saved_target_env_var [list]
259 if { [info exists set_target_env_var] \
260 && [llength $set_target_env_var] != 0 } {
261 if { [is_remote target] } {
262 return [list "unsupported" ""]
264 set-target-env-var
266 set result [eval [list saved_${tool}_load $program] $args]
267 if { [info exists set_target_env_var] \
268 && [llength $set_target_env_var] != 0 } {
269 restore-target-env-var
271 if { $shouldfail != 0 } {
272 switch [lindex $result 0] {
273 "pass" { set status "fail" }
274 "fail" { set status "pass" }
276 set result [list $status [lindex $result 1]]
278 return $result
282 proc dg-set-target-env-var { args } {
283 global set_target_env_var
284 if { [llength $args] != 3 } {
285 error "dg-set-target-env-var: need two arguments"
286 return
288 lappend set_target_env_var [list [lindex $args 1] [lindex $args 2]]
291 proc set-target-env-var { } {
292 global set_target_env_var
293 upvar 1 saved_target_env_var saved_target_env_var
294 foreach env_var $set_target_env_var {
295 set var [lindex $env_var 0]
296 set value [lindex $env_var 1]
297 if [info exists env($var)] {
298 lappend saved_target_env_var [list $var 1 $env($var)]
299 } else {
300 lappend saved_target_env_var [list $var 0]
302 setenv $var $value
306 proc restore-target-env-var { } {
307 upvar 1 saved_target_env_var saved_target_env_var
308 for { set env_vari [llength $saved_target_env_var] } {
309 [incr env_vari -1] >= 0 } {} {
310 set env_var [lindex $saved_target_env_var $env_vari]
311 set var [lindex $env_var 0]
312 if [lindex $env_var 1] {
313 setenv $var [lindex $env_var 2]
314 } else {
315 unsetenv $var
320 # Utility routines.
323 # search_for -- looks for a string match in a file
325 proc search_for { file pattern } {
326 set fd [open $file r]
327 while { [gets $fd cur_line]>=0 } {
328 if [string match "*$pattern*" $cur_line] then {
329 close $fd
330 return 1
333 close $fd
334 return 0
337 # Modified dg-runtest that can cycle through a list of optimization options
338 # as c-torture does.
339 proc gcc-dg-runtest { testcases default-extra-flags } {
340 global runtests
342 # Some callers set torture options themselves; don't override those.
343 set existing_torture_options [torture-options-exist]
344 if { $existing_torture_options == 0 } {
345 global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
346 torture-init
347 set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS
349 dump-torture-options
351 foreach test $testcases {
352 global torture_with_loops torture_without_loops
353 # If we're only testing specific files and this isn't one of
354 # them, skip it.
355 if ![runtest_file_p $runtests $test] {
356 continue
359 # Look for a loop within the source code - if we don't find one,
360 # don't pass -funroll[-all]-loops.
361 if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
362 set option_list $torture_with_loops
363 } else {
364 set option_list $torture_without_loops
367 set nshort [file tail [file dirname $test]]/[file tail $test]
369 foreach flags $option_list {
370 verbose "Testing $nshort, $flags" 1
371 dg-test $test $flags ${default-extra-flags}
375 if { $existing_torture_options == 0 } {
376 torture-finish
380 proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
381 global srcdir subdir
383 if ![info exists DEBUG_TORTURE_OPTIONS] {
384 set DEBUG_TORTURE_OPTIONS ""
385 foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
386 set comp_output [$target_compile \
387 "$srcdir/$subdir/$trivial" "trivial.S" assembly \
388 "additional_flags=$type"]
389 if { ! [string match "*: target system does not support the * debug format*" \
390 $comp_output] } {
391 remove-build-file "trivial.S"
392 foreach level {1 "" 3} {
393 if { ($type == "-gdwarf-2") && ($level != "") } {
394 lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
395 foreach opt $opt_opts {
396 lappend DEBUG_TORTURE_OPTIONS \
397 [list "${type}" "-g${level}" "$opt" ]
399 } else {
400 lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
401 foreach opt $opt_opts {
402 lappend DEBUG_TORTURE_OPTIONS \
403 [list "${type}${level}" "$opt" ]
411 verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
413 global runtests
415 foreach test $testcases {
416 # If we're only testing specific files and this isn't one of
417 # them, skip it.
418 if ![runtest_file_p $runtests $test] {
419 continue
422 set nshort [file tail [file dirname $test]]/[file tail $test]
424 foreach flags $DEBUG_TORTURE_OPTIONS {
425 set doit 1
427 # These tests check for information which may be deliberately
428 # suppressed at -g1.
429 if { ([string match {*/debug-[126].c} "$nshort"] \
430 || [string match {*/enum-1.c} "$nshort"] \
431 || [string match {*/enum-[12].C} "$nshort"]) \
432 && ([string match "*1" [lindex "$flags" 0] ]
433 || [lindex "$flags" 1] == "-g1") } {
434 set doit 0
437 # High optimization can remove the variable whose existence is tested.
438 # Dwarf debugging with commentary (-dA) preserves the symbol name in the
439 # assembler output, but stabs debugging does not.
440 # http://gcc.gnu.org/ml/gcc-regression/2003-04/msg00095.html
441 if { [string match {*/debug-[12].c} "$nshort"] \
442 && [string match "*O*" "$flags"] \
443 && ( [string match "*coff*" "$flags"] \
444 || [string match "*stabs*" "$flags"] ) } {
445 set doit 0
448 if { $doit } {
449 verbose -log "Testing $nshort, $flags" 1
450 dg-test $test $flags ""
456 # Prune any messages matching ARGS[1] (a regexp) from test output.
457 proc dg-prune-output { args } {
458 global additional_prunes
460 if { [llength $args] != 2 } {
461 error "[lindex $args 1]: need one argument"
462 return
465 lappend additional_prunes [lindex $args 1]
468 # Remove files matching the pattern from the build machine.
469 proc remove-build-file { pat } {
470 verbose "remove-build-file `$pat'" 2
471 set file_list "[glob -nocomplain $pat]"
472 verbose "remove-build-file `$file_list'" 2
473 foreach output_file $file_list {
474 if [is_remote host] {
475 # Ensure the host knows the file is gone by deleting there
476 # first.
477 remote_file host delete $output_file
479 remote_file build delete $output_file
483 # Remove runtime-generated profile file for the current test.
484 proc cleanup-profile-file { } {
485 remove-build-file "mon.out"
486 remove-build-file "gmon.out"
489 # Remove compiler-generated coverage files for the current test.
490 proc cleanup-coverage-files { } {
491 set testcase [testname-for-summary]
492 # The name might include a list of options; extract the file name.
493 set testcase [lindex $testcase 0]
494 remove-build-file "[file rootname [file tail $testcase]].gc??"
496 # Clean up coverage files for additional source files.
497 if [info exists additional_sources] {
498 foreach srcfile $additional_sources {
499 remove-build-file "[file rootname [file tail $srcfile]].gc??"
504 # Remove compiler-generated files from -repo for the current test.
505 proc cleanup-repo-files { } {
506 set testcase [testname-for-summary]
507 # The name might include a list of options; extract the file name.
508 set testcase [lindex $testcase 0]
509 remove-build-file "[file rootname [file tail $testcase]].o"
510 remove-build-file "[file rootname [file tail $testcase]].rpo"
512 # Clean up files for additional source files.
513 if [info exists additional_sources] {
514 foreach srcfile $additional_sources {
515 remove-build-file "[file rootname [file tail $srcfile]].o"
516 remove-build-file "[file rootname [file tail $srcfile]].rpo"
521 # Remove compiler-generated RTL dump files for the current test.
523 # SUFFIX is the filename suffix pattern.
524 proc cleanup-rtl-dump { suffix } {
525 cleanup-dump "\[0-9\]\[0-9\]\[0-9\]r.$suffix"
528 # Remove a specific tree dump file for the current test.
530 # SUFFIX is the tree dump file suffix pattern.
531 proc cleanup-tree-dump { suffix } {
532 cleanup-dump "\[0-9\]\[0-9\]\[0-9\]t.$suffix"
535 # Remove a specific ipa dump file for the current test.
537 # SUFFIX is the ipa dump file suffix pattern.
538 proc cleanup-ipa-dump { suffix } {
539 cleanup-dump "\[0-9\]\[0-9\]\[0-9\]i.$suffix"
542 # Remove a stack usage file for the current test.
543 proc cleanup-stack-usage { } {
544 set testcase [testname-for-summary]
545 # The name might include a list of options; extract the file name.
546 set testcase [lindex $testcase 0]
547 remove-build-file "[file rootname [file tail $testcase]].su"
549 # Clean up files for additional source files.
550 if [info exists additional_sources] {
551 foreach srcfile $additional_sources {
552 remove-build-file "[file rootname [file tail $srcfile]].su"
557 # Remove an Ada spec file for the current test.
558 proc cleanup-ada-spec { } {
559 set testcase [testname-for-summary]
560 remove-build-file "[get_ada_spec_filename $testcase]"
562 # Clean up files for additional source files.
563 if [info exists additional_sources] {
564 foreach srcfile $additional_sources {
565 remove-build-file "[get_ada_spec_filename $srcfile]"
570 # Remove all dump files with the provided suffix.
571 proc cleanup-dump { suffix } {
572 set testcase [testname-for-summary]
573 # The name might include a list of options; extract the file name.
574 set src [file tail [lindex $testcase 0]]
575 remove-build-file "[file tail $src].$suffix"
576 remove-build-file "[file rootname [file tail $src]].exe.$suffix"
577 remove-build-file "[file rootname [file tail $src]].exe.ltrans\[0-9\]*.$suffix"
578 # -fcompare-debug dumps
579 remove-build-file "[file tail $src].gk.$suffix"
581 # Clean up dump files for additional source files.
582 if [info exists additional_sources] {
583 foreach srcfile $additional_sources {
584 remove-build-file "[file tail $srcfile].$suffix"
585 remove-build-file "[file rootname [file tail $srcfile]].exe.$suffix"
586 remove-build-file "[file rootname [file tail $srcfile]].exe.ltrans\[0-9\]*.$suffix"
587 # -fcompare-debug dumps
588 remove-build-file "[file tail $srcfile].gk.$suffix"
593 # Remove files kept by --save-temps for the current test.
595 # Currently this is only .i, .ii, .s and .o files, but more can be added
596 # if there are tests generating them.
597 # ARGS is a list of suffixes to NOT delete.
598 proc cleanup-saved-temps { args } {
599 global additional_sources
600 set suffixes {}
602 # add the to-be-kept suffixes
603 foreach suffix {".mii" ".ii" ".i" ".s" ".o" ".gkd" ".res" ".ltrans.out"} {
604 if {[lsearch $args $suffix] < 0} {
605 lappend suffixes $suffix
609 set testcase [testname-for-summary]
610 # The name might include a list of options; extract the file name.
611 set testcase [lindex $testcase 0]
612 foreach suffix $suffixes {
613 remove-build-file "[file rootname [file tail $testcase]]$suffix"
614 remove-build-file "[file rootname [file tail $testcase]].exe$suffix"
615 remove-build-file "[file rootname [file tail $testcase]].exe.ltrans\[0-9\]*$suffix"
616 # -fcompare-debug dumps
617 remove-build-file "[file rootname [file tail $testcase]].gk$suffix"
620 # Clean up saved temp files for additional source files.
621 if [info exists additional_sources] {
622 foreach srcfile $additional_sources {
623 foreach suffix $suffixes {
624 remove-build-file "[file rootname [file tail $srcfile]]$suffix"
625 remove-build-file "[file rootname [file tail $srcfile]].exe$suffix"
626 remove-build-file "[file rootname [file tail $srcfile]].exe.ltrans\[0-9\]*$suffix"
628 # -fcompare-debug dumps
629 remove-build-file "[file rootname [file tail $srcfile]].gk$suffix"
635 # Scan Fortran modules for a given regexp.
637 # Argument 0 is the module name
638 # Argument 1 is the regexp to match
639 proc scan-module { args } {
640 set modfilename [string tolower [lindex $args 0]].mod
641 set fd [open [list | gzip -dc $modfilename] r]
642 set text [read $fd]
643 close $fd
645 set testcase [testname-for-summary]
646 if [regexp -- [lindex $args 1] $text] {
647 pass "$testcase scan-module [lindex $args 1]"
648 } else {
649 fail "$testcase scan-module [lindex $args 1]"
653 # Scan Fortran modules for absence of a given regexp.
655 # Argument 0 is the module name
656 # Argument 1 is the regexp to match
657 proc scan-module-absence { args } {
658 set modfilename [string tolower [lindex $args 0]].mod
659 set fd [open [list | gzip -dc $modfilename] r]
660 set text [read $fd]
661 close $fd
663 set testcase [testname-for-summary]
664 if [regexp -- [lindex $args 1] $text] {
665 fail "$testcase scan-module [lindex $args 1]"
666 } else {
667 pass "$testcase scan-module [lindex $args 1]"
671 # Verify that the compiler output file exists, invoked via dg-final.
672 proc output-exists { args } {
673 # Process an optional target or xfail list.
674 if { [llength $args] >= 1 } {
675 switch [dg-process-target [lindex $args 0]] {
676 "S" { }
677 "N" { return }
678 "F" { setup_xfail "*-*-*" }
679 "P" { }
683 set testcase [testname-for-summary]
684 # Access variable from gcc-dg-test-1.
685 upvar 2 output_file output_file
687 if [file exists $output_file] {
688 pass "$testcase output-exists $output_file"
689 } else {
690 fail "$testcase output-exists $output_file"
694 # Verify that the compiler output file does not exist, invoked via dg-final.
695 proc output-exists-not { args } {
696 # Process an optional target or xfail list.
697 if { [llength $args] >= 1 } {
698 switch [dg-process-target [lindex $args 0]] {
699 "S" { }
700 "N" { return }
701 "F" { setup_xfail "*-*-*" }
702 "P" { }
706 set testcase [testname-for-summary]
707 # Access variable from gcc-dg-test-1.
708 upvar 2 output_file output_file
710 if [file exists $output_file] {
711 fail "$testcase output-exists-not $output_file"
712 } else {
713 pass "$testcase output-exists-not $output_file"
717 # We need to make sure that additional_* are cleared out after every
718 # test. It is not enough to clear them out *before* the next test run
719 # because gcc-target-compile gets run directly from some .exp files
720 # (outside of any test). (Those uses should eventually be eliminated.)
722 # Because the DG framework doesn't provide a hook that is run at the
723 # end of a test, we must replace dg-test with a wrapper.
725 if { [info procs saved-dg-test] == [list] } {
726 rename dg-test saved-dg-test
728 proc dg-test { args } {
729 global additional_files
730 global additional_sources
731 global additional_prunes
732 global errorInfo
733 global compiler_conditional_xfail_data
734 global shouldfail
735 global testname_with_flags
736 global set_target_env_var
738 if { [ catch { eval saved-dg-test $args } errmsg ] } {
739 set saved_info $errorInfo
740 set additional_files ""
741 set additional_sources ""
742 set additional_prunes ""
743 set shouldfail 0
744 if [info exists compiler_conditional_xfail_data] {
745 unset compiler_conditional_xfail_data
747 if [info exists testname_with_flags] {
748 unset testname_with_flags
750 unset_timeout_vars
751 error $errmsg $saved_info
753 set additional_files ""
754 set additional_sources ""
755 set additional_prunes ""
756 set shouldfail 0
757 if [info exists set_target_env_var] {
758 unset set_target_env_var
760 unset_timeout_vars
761 if [info exists compiler_conditional_xfail_data] {
762 unset compiler_conditional_xfail_data
764 if [info exists testname_with_flags] {
765 unset testname_with_flags
770 if { [info procs saved-dg-warning] == [list] \
771 && [info exists gcc_warning_prefix] } {
772 rename dg-warning saved-dg-warning
774 proc dg-warning { args } {
775 # Make this variable available here and to the saved proc.
776 upvar dg-messages dg-messages
777 global gcc_warning_prefix
779 process-message saved-dg-warning "$gcc_warning_prefix" "$args"
783 if { [info procs saved-dg-error] == [list] \
784 && [info exists gcc_error_prefix] } {
785 rename dg-error saved-dg-error
787 proc dg-error { args } {
788 # Make this variable available here and to the saved proc.
789 upvar dg-messages dg-messages
790 global gcc_error_prefix
792 process-message saved-dg-error "$gcc_error_prefix" "$args"
795 # Override dg-bogus at the same time. It doesn't handle a prefix
796 # but its expression should include a column number. Otherwise the
797 # line number can match the column number for other messages, leading
798 # to insanity.
799 rename dg-bogus saved-dg-bogus
801 proc dg-bogus { args } {
802 upvar dg-messages dg-messages
803 process-message saved-dg-bogus "" $args
807 # Modify the regular expression saved by a DejaGnu message directive to
808 # include a prefix and to force the expression to match a single line.
809 # MSGPROC is the procedure to call.
810 # MSGPREFIX is the prefix to prepend.
811 # DGARGS is the original argument list.
813 proc process-message { msgproc msgprefix dgargs } {
814 upvar dg-messages dg-messages
816 # Process the dg- directive, including adding the regular expression
817 # to the new message entry in dg-messages.
818 set msgcnt [llength ${dg-messages}]
819 eval $msgproc $dgargs
821 # If the target expression wasn't satisfied there is no new message.
822 if { [llength ${dg-messages}] == $msgcnt } {
823 return;
826 # Get the entry for the new message. Prepend the message prefix to
827 # the regular expression and make it match a single line.
828 set newentry [lindex ${dg-messages} end]
829 set expmsg [lindex $newentry 2]
831 # Handle column numbers from the specified expression (if there is
832 # one) and set up the search expression that will be used by DejaGnu.
833 if [regexp "^(\[0-9\]+):" $expmsg "" column] {
834 # The expression in the directive included a column number.
835 # Remove "COLUMN:" from the original expression and move it
836 # to the proper place in the search expression.
837 regsub "^\[0-9\]+:" $expmsg "" expmsg
838 set expmsg "$column: $msgprefix\[^\n\]*$expmsg"
839 } elseif [string match "" [lindex $newentry 0]] {
840 # The specified line number is 0; don't expect a column number.
841 set expmsg "$msgprefix\[^\n\]*$expmsg"
842 } else {
843 # There is no column number in the search expression, but we
844 # should expect one in the message itself.
845 set expmsg "\[0-9\]+: $msgprefix\[^\n\]*$expmsg"
848 set newentry [lreplace $newentry 2 2 $expmsg]
849 set dg-messages [lreplace ${dg-messages} end end $newentry]
850 verbose "process-message:\n${dg-messages}" 2
853 # Look for messages that don't have standard prefixes.
855 proc dg-message { args } {
856 upvar dg-messages dg-messages
857 process-message saved-dg-warning "" $args
860 # Check the existence of a gdb in the path, and return true if there
861 # is one.
863 # Set env(GDB_FOR_GCC_TESTING) accordingly.
865 proc gdb-exists { args } {
866 if ![info exists ::env(GDB_FOR_GCC_TESTING)] {
867 global GDB
868 if ![info exists ::env(GDB_FOR_GCC_TESTING)] {
869 if [info exists GDB] {
870 setenv GDB_FOR_GCC_TESTING "$GDB"
871 } else {
872 setenv GDB_FOR_GCC_TESTING "[transform gdb]"
876 if { [which $::env(GDB_FOR_GCC_TESTING)] != 0 } {
877 return 1;
879 return 0;
882 set additional_prunes ""
883 set dg_runtest_extra_prunes ""