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 #
[name]:[locus
]: Error
: (1)
56 #
[name]:[locus2
]: Error
: Some error at
(1) and
(2)
58 # Where
[locus
] is either
[line
] or
[line
].
[column
] or
59 #
[line
].
[column
]-[column
] .
61 # We collapse these to look like
:
62 #
[name]:[line
]:[column
]: Error
: Some error at
(1) and
(2)
64 #
[name]:[line
]:[column
]: Error
: Some error at
(1) and
(2)
65 #
[name]:[line2
]:[column
]: Error
: Some error at
(1) and
(2)
67 # Note that these regexps only make sense in the combinations used below.
68 # Note also that is imperative that we first deal with the form with
70 set locus_regexp
"(\[^\n\]+:\[0-9\]+)\[\.:\](\[0-9\]+)(-\[0-9\]+)?:\n\n\[^\n\]+\n\[^\n\]+\n"
71 set diag_regexp
"(\[^\n\]+)\n"
73 # We proceed in steps
:
75 #
1. We add first a column number
if none exists.
76 #
(Some Fortran diagnostics have the locus after Warning|Error
)
77 set colnum_regexp
"(^|\n)(Warning: |Error: )?(\[^:\n\]+:\[0-9\]+):(\[ \n\])"
78 regsub
-all $colnum_regexp $comp_output
"\\1\\3:0:\\4\\2" comp_output
79 verbose
"comput_output0:\n$comp_output"
81 #
2. We deal with the form with two different locus lines
,
82 set two_loci
"(^|\n)$locus_regexp$locus_regexp$diag_regexp"
83 regsub
-all $two_loci $comp_output
"\\1\\2:\\3: \\8\n\\5\:\\6: \\8\n" comp_output
84 verbose
"comput_output1:\n$comp_output"
86 set locus_prefix
"(\[^:\n\]+:\[0-9\]+:\[0-9\]+: )(Warning: |Error: )"
87 set two_loci2
"(^|\n)$locus_prefix\\(1\\)\n$locus_prefix$diag_regexp"
88 regsub
-all $two_loci2 $comp_output
"\\1\\2\\3\\6\n\\4\\5\\6\n" comp_output
89 verbose
"comput_output2:\n$comp_output"
91 #
3.
then with the form with only one locus line.
92 set single_locus
"(^|\n)$locus_regexp$diag_regexp"
93 regsub
-all $single_locus $comp_output
"\\1\\2:\\3: \\5\n" comp_output
94 verbose
"comput_output3:\n$comp_output"
96 #
4. Add a line number
if none exists
97 regsub
-all
"(^|\n)(Warning: |Error: )" $comp_output "\\1:0:0: \\2" comp_output
98 verbose
"comput_output4:\n$comp_output"
99 return [list $comp_output $output_file
]
102 proc gfortran
-dg
-prune
{ system text } {
103 return [gcc
-dg
-prune $
system $
text]
108 # Modified dg
-runtest that can cycle through a list of optimization options
110 proc gfortran
-dg
-runtest
{ testcases flags default
-extra
-flags
} {
112 global DG_TORTURE_OPTIONS torture_with_loops
115 set-torture
-options $DG_TORTURE_OPTIONS
117 foreach test $testcases
{
118 #
If we
're only testing specific files and this isn't one of
120 if ![runtest_file_p $runtests $test
] {
124 # look
if this is dg
-do-run test
, in which case
125 # we cycle through the option list
, otherwise we don
't
126 if [expr [search_for $test "dg-do run"]] {
127 set option_list $torture_with_loops
129 set option_list [list { -O } ]
132 set nshort [file tail [file dirname $test]]/[file tail $test]
133 list-module-names $test
135 foreach flags_t $option_list {
136 verbose "Testing $nshort, $flags $flags_t" 1
137 dg-test $test "$flags $flags_t" ${default-extra-flags}
145 proc gfortran-dg-debug-runtest { target_compile trivial opt_opts testcases } {
146 global srcdir subdir DEBUG_TORTURE_OPTIONS
148 if ![info exists DEBUG_TORTURE_OPTIONS] {
149 set DEBUG_TORTURE_OPTIONS ""
150 set type_list [list "-gstabs" "-gstabs+" "-gxcoff" "-gxcoff+" "-gcoff" "-gdwarf-2" ]
151 foreach type $type_list {
152 set comp_output [$target_compile \
153 "$srcdir/$subdir/$trivial" "trivial.S" assembly \
154 "additional_flags=$type"]
155 if { [string match "exit status *" $comp_output] } {
159 "* target system does not support the * debug format*" \
164 remove-build-file "trivial.S"
165 foreach level {1 "" 3} {
166 if { ($type == "-gdwarf-2") && ($level != "") } {
167 lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
168 foreach opt $opt_opts {
169 lappend DEBUG_TORTURE_OPTIONS \
170 [list "${type}" "-g${level}" "$opt" ]
173 lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
174 foreach opt $opt_opts {
175 lappend DEBUG_TORTURE_OPTIONS \
176 [list "${type}${level}" "$opt" ]
183 verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
187 foreach test $testcases {
188 # If we're only testing specific files and this isn
't one of
190 if ![runtest_file_p $runtests $test] {
194 set nshort [file tail [file dirname $test]]/[file tail $test]
195 list-module-names $test
197 foreach flags $DEBUG_TORTURE_OPTIONS {
199 # gcc-specific checking removed here
202 verbose -log "Testing $nshort, $flags" 1
203 dg-test $test $flags ""