1 # Copyright (C) 2004-2015 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)
53 # [name]:[locus]: Error: Some error
55 # Where [locus] is either [line] or [line].[column] or
56 # [line].[column]-[column] .
58 # We collapse these to look like:
59 # [name]:[line]:[column]: Error: Some error at (1) and (2)
61 # [name]:[line]:[column]: Error: Some error at (1) and (2)
62 # [name]:[line2]:[column]: Error: Some error at (1) and (2)
64 # Note that these regexps only make sense in the combinations used below.
65 # Note also that is imperative that we first deal with the form with
67 set locus_regexp "(\[^\n\]+:\[0-9\]+)\[\.:\](\[0-9\]+)(-\[0-9\]+)?:\n\n\[^\n\]+\n\[^\n\]+\n"
68 set diag_regexp "(\[^\n\]+)\n"
70 # We proceed in steps:
72 # 1. We add first a column number if none exists.
73 # (Some Fortran diagnostics have the locus after Warning|Error)
74 set colnum_regexp "(^|\n)(Warning: |Error: )?(\[^:\n\]+:\[0-9\]+):(\[ \n\])"
75 regsub -all $colnum_regexp $comp_output "\\1\\3:0:\\4\\2" comp_output
76 verbose "comput_output0:\n$comp_output"
78 # 2. We deal with the form with two different locus lines,
79 set two_loci "(^|\n)$locus_regexp$locus_regexp$diag_regexp"
80 regsub -all $two_loci $comp_output "\\1\\2:\\3: \\8\n\\5\:\\6: \\8\n" comp_output
81 verbose "comput_output1:\n$comp_output"
83 # 3. then with the form with only one locus line.
84 set single_locus "(^|\n)$locus_regexp$diag_regexp"
85 regsub -all $single_locus $comp_output "\\1\\2:\\3: \\5\n" comp_output
86 verbose "comput_output2:\n$comp_output"
88 # 4. Add a line number if none exists
89 regsub -all "(^|\n)(Warning: |Error: )" $comp_output "\\1:0:0: \\2" comp_output
90 verbose "comput_output3:\n$comp_output"
91 return [list $comp_output $output_file]
94 proc gfortran-dg-prune { system text } {
95 return [gcc-dg-prune $system $text]
100 # Modified dg-runtest that can cycle through a list of optimization options
102 proc gfortran-dg-runtest { testcases flags default-extra-flags } {
104 global DG_TORTURE_OPTIONS torture_with_loops
107 set-torture-options $DG_TORTURE_OPTIONS
109 foreach test $testcases {
110 # If we're only testing specific files and this isn't one of
112 if ![runtest_file_p $runtests $test] {
116 # look if this is dg-do-run test, in which case
117 # we cycle through the option list, otherwise we don't
118 if [expr [search_for $test "dg-do run"]] {
119 set option_list $torture_with_loops
121 set option_list [list { -O } ]
124 set nshort [file tail [file dirname $test]]/[file tail $test]
125 list-module-names $test
127 foreach flags_t $option_list {
128 verbose "Testing $nshort, $flags $flags_t" 1
129 dg-test $test "$flags $flags_t" ${default-extra-flags}
137 proc gfortran-dg-debug-runtest { target_compile trivial opt_opts testcases } {
138 global srcdir subdir DEBUG_TORTURE_OPTIONS
140 if ![info exists DEBUG_TORTURE_OPTIONS] {
141 set DEBUG_TORTURE_OPTIONS ""
142 set type_list [list "-gstabs" "-gstabs+" "-gxcoff" "-gxcoff+" "-gcoff" "-gdwarf-2" ]
143 foreach type $type_list {
144 set comp_output [$target_compile \
145 "$srcdir/$subdir/$trivial" "trivial.S" assembly \
146 "additional_flags=$type"]
147 if { [string match "exit status *" $comp_output] } {
151 "* target system does not support the * debug format*" \
156 remove-build-file "trivial.S"
157 foreach level {1 "" 3} {
158 if { ($type == "-gdwarf-2") && ($level != "") } {
159 lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
160 foreach opt $opt_opts {
161 lappend DEBUG_TORTURE_OPTIONS \
162 [list "${type}" "-g${level}" "$opt" ]
165 lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
166 foreach opt $opt_opts {
167 lappend DEBUG_TORTURE_OPTIONS \
168 [list "${type}${level}" "$opt" ]
175 verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
179 foreach test $testcases {
180 # If we're only testing specific files and this isn't one of
182 if ![runtest_file_p $runtests $test] {
186 set nshort [file tail [file dirname $test]]/[file tail $test]
187 list-module-names $test
189 foreach flags $DEBUG_TORTURE_OPTIONS {
191 # gcc-specific checking removed here
194 verbose -log "Testing $nshort, $flags" 1
195 dg-test $test $flags ""