1 # Copyright (C) 2004, 2005, 2006, 2007, 2008 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/>.
18 load_lib torture-options.exp
20 # Define gfortran callbacks for dg.exp.
22 proc gfortran-dg-test { prog do_what extra_tool_flags } {
24 [gcc-dg-test-1 gfortran_target_compile $prog $do_what $extra_tool_flags]
26 set comp_output [lindex $result 0]
27 set output_file [lindex $result 1]
29 # gfortran error messages look like this:
34 # Error: Some error at (1)
44 # Error: Some error at (1) and (2)
48 # some code and some more code
50 # Error: Some error at (1) and (2)
52 # Where [locus] is either [line] or [line].[columns] .
54 # We collapse these to look like:
55 # [name]:[line]: Error: Some error at (1) and (2)
57 # [name]:[line]: Error: Some error at (1) and (2)
58 # [name]:[line2]: Error: Some error at (1) and (2)
59 # We proceed in two steps: first we deal with the form with two
60 # different locus lines, then with the form with only one locus line.
62 # Note that these regexps only make sense in the combinations used below.
63 # Note also that is imperative that we first deal with the form with
65 set locus_regexp "(\[^\n\]*):(\[0-9\]*)\[^\n\]*:\n\n\[^\n\]*\n\[^\n\]*\n"
66 set diag_regexp "(\[^\n\]*)\n"
68 set two_loci "$locus_regexp$locus_regexp$diag_regexp"
69 set single_locus "$locus_regexp$diag_regexp"
70 regsub -all $two_loci $comp_output "\\1:\\2: \\5\n\\3:\\4: \\5\n" comp_output
71 regsub -all $single_locus $comp_output "\\1:\\2: \\3\n" comp_output
73 return [list $comp_output $output_file]
76 proc gfortran-dg-prune { system text } {
77 return [gcc-dg-prune $system $text]
82 # Modified dg-runtest that can cycle through a list of optimization options
84 proc gfortran-dg-runtest { testcases default-extra-flags } {
86 global DG_TORTURE_OPTIONS torture_with_loops
89 set-torture-options $DG_TORTURE_OPTIONS
91 foreach test $testcases {
92 # If we're only testing specific files and this isn't one of
94 if ![runtest_file_p $runtests $test] {
98 # look if this is dg-do-run test, in which case
99 # we cycle through the option list, otherwise we don't
100 if [expr [search_for $test "dg-do run"]] {
101 set option_list $torture_with_loops
103 set option_list [list { -O } ]
106 set nshort [file tail [file dirname $test]]/[file tail $test]
108 foreach flags $option_list {
109 verbose "Testing $nshort, $flags" 1
110 dg-test $test $flags ${default-extra-flags}
117 proc gfortran-dg-debug-runtest { target_compile trivial opt_opts testcases } {
118 global srcdir subdir DEBUG_TORTURE_OPTIONS
120 if ![info exists DEBUG_TORTURE_OPTIONS] {
121 set DEBUG_TORTURE_OPTIONS ""
122 set type_list [list "-gstabs" "-gstabs+" "-gxcoff" "-gxcoff+" "-gcoff" "-gdwarf-2" ]
123 foreach type $type_list {
124 set comp_output [$target_compile \
125 "$srcdir/$subdir/$trivial" "trivial.S" assembly \
126 "additional_flags=$type"]
127 if { [string match "exit status *" $comp_output] } {
131 "* target system does not support the * debug format*" \
136 remove-build-file "trivial.S"
137 foreach level {1 "" 3} {
138 lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
139 foreach opt $opt_opts {
140 lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}" \
147 verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
151 foreach test $testcases {
152 # If we're only testing specific files and this isn't one of
154 if ![runtest_file_p $runtests $test] {
158 set nshort [file tail [file dirname $test]]/[file tail $test]
160 foreach flags $DEBUG_TORTURE_OPTIONS {
162 # gcc-specific checking removed here
165 verbose -log "Testing $nshort, $flags" 1
166 dg-test $test $flags ""