]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/lib/gfortran-dg.exp
Delete obsolete SDB debug info support.
[thirdparty/gcc.git] / gcc / testsuite / lib / gfortran-dg.exp
1 # Copyright (C) 2004-2017 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 load_lib gcc-dg.exp
18 load_lib torture-options.exp
19
20 # Define gfortran callbacks for dg.exp.
21
22 proc gfortran-dg-test { prog do_what extra_tool_flags } {
23 set result \
24 [gcc-dg-test-1 gfortran_target_compile $prog $do_what $extra_tool_flags]
25
26 set comp_output [lindex $result 0]
27 set output_file [lindex $result 1]
28
29 # gcc's default is to print the caret and source code, but
30 # most test cases implicitly use the flag -fno-diagnostics-show-caret
31 # to disable caret (and source code) printing.
32 #
33 # However, a few test cases override this back to the default by
34 # explicily supplying "-fdiagnostics-show-caret", so that we can have
35 # test coverage for caret/source code printing.
36 #
37 # gfortran error messages with caret-printing look like this:
38 # [name]:[locus]:
39 #
40 # some code
41 # 1
42 # Error: Some error at (1)
43 # or
44 # [name]:[locus]:
45 #
46 # some code
47 # 1
48 # [name]:[locus2]:
49 #
50 # some other code
51 # 2
52 # Error: Some error at (1) and (2)
53 # or
54 # [name]:[locus]:
55 #
56 # some code and some more code
57 # 1 2
58 # Error: Some error at (1) and (2)
59 #
60 # If this is such a test case, skip the rest of this function, so
61 # that the test case can explicitly verify the output that it expects.
62 if {[string first "-fdiagnostics-show-caret" $extra_tool_flags] >= 0} {
63 return [list $comp_output $output_file]
64 }
65
66 # Otherwise, caret-printing is disabled.
67 # gfortran errors with caret-printing disabled look like this:
68 # [name]:[locus]: Error: Some error
69 # or
70 # [name]:[locus]: Error: (1)
71 # [name]:[locus2]: Error: Some error at (1) and (2)
72 #
73 # Where [locus] is either [line] or [line].[column] or
74 # [line].[column]-[column] .
75 #
76 # We collapse these to look like:
77 # [name]:[line]:[column]: Error: Some error at (1) and (2)
78 # or
79 # [name]:[line]:[column]: Error: Some error at (1) and (2)
80 # [name]:[line2]:[column]: Error: Some error at (1) and (2)
81 #
82 # Note that these regexps only make sense in the combinations used below.
83 # Note also that is imperative that we first deal with the form with
84 # two loci.
85 set locus_regexp "(\[^\n\]+:\[0-9\]+)\[\.:\](\[0-9\]+)(-\[0-9\]+)?:\n\n\[^\n\]+\n\[^\n\]+\n"
86 set diag_regexp "(\[^\n\]+)\n"
87
88 # We proceed in steps:
89
90 # 1. We add first a column number if none exists.
91 # (Some Fortran diagnostics have the locus after Warning|Error)
92 set colnum_regexp "(^|\n)(Warning: |Error: )?(\[^:\n\]+:\[0-9\]+):(\[ \n\])"
93 regsub -all $colnum_regexp $comp_output "\\1\\3:0:\\4\\2" comp_output
94 verbose "comput_output0:\n$comp_output"
95
96 # 2. We deal with the form with two different locus lines,
97 set two_loci "(^|\n)$locus_regexp$locus_regexp$diag_regexp"
98 regsub -all $two_loci $comp_output "\\1\\2:\\3: \\8\n\\5\:\\6: \\8\n" comp_output
99 verbose "comput_output1:\n$comp_output"
100
101 set locus_prefix "(\[^:\n\]+:\[0-9\]+:\[0-9\]+: )(Warning: |Error: )"
102 set two_loci2 "(^|\n)$locus_prefix\\(1\\)\n$locus_prefix$diag_regexp"
103 regsub -all $two_loci2 $comp_output "\\1\\2\\3\\6\n\\4\\5\\6\n" comp_output
104 verbose "comput_output2:\n$comp_output"
105
106 # 3. then with the form with only one locus line.
107 set single_locus "(^|\n)$locus_regexp$diag_regexp"
108 regsub -all $single_locus $comp_output "\\1\\2:\\3: \\5\n" comp_output
109 verbose "comput_output3:\n$comp_output"
110
111 # 4. Add a line number if none exists
112 regsub -all "(^|\n)(Warning: |Error: )" $comp_output "\\1:0:0: \\2" comp_output
113 verbose "comput_output4:\n$comp_output"
114 return [list $comp_output $output_file]
115 }
116
117 proc gfortran-dg-prune { system text } {
118 return [gcc-dg-prune $system $text]
119 }
120
121 # Utility routines.
122
123 # Modified dg-runtest that can cycle through a list of optimization options
124 # as c-torture does.
125 proc gfortran-dg-runtest { testcases flags default-extra-flags } {
126 global runtests
127 global DG_TORTURE_OPTIONS torture_with_loops
128
129 torture-init
130 set-torture-options $DG_TORTURE_OPTIONS
131
132 foreach test $testcases {
133 # If we're only testing specific files and this isn't one of
134 # them, skip it.
135 if ![runtest_file_p $runtests $test] {
136 continue
137 }
138
139 # look if this is dg-do-run test, in which case
140 # we cycle through the option list, otherwise we don't
141 if [expr [search_for $test "dg-do run"]] {
142 set option_list $torture_with_loops
143 } else {
144 set option_list [list { -O } ]
145 }
146
147 set nshort [file tail [file dirname $test]]/[file tail $test]
148 list-module-names $test
149
150 foreach flags_t $option_list {
151 verbose "Testing $nshort, $flags $flags_t" 1
152 dg-test $test "$flags $flags_t" ${default-extra-flags}
153 cleanup-modules ""
154 }
155 }
156
157 torture-finish
158 }
159
160 proc gfortran-dg-debug-runtest { target_compile trivial opt_opts testcases } {
161 global srcdir subdir DEBUG_TORTURE_OPTIONS
162
163 if ![info exists DEBUG_TORTURE_OPTIONS] {
164 set DEBUG_TORTURE_OPTIONS ""
165 set type_list [list "-gstabs" "-gstabs+" "-gxcoff" "-gxcoff+" "-gdwarf-2" ]
166 foreach type $type_list {
167 set comp_output [$target_compile \
168 "$srcdir/$subdir/$trivial" "trivial.S" assembly \
169 "additional_flags=$type"]
170 if { [string match "exit status *" $comp_output] } {
171 continue
172 }
173 if { [string match \
174 "* target system does not support the * debug format*" \
175 $comp_output]
176 } {
177 continue
178 }
179 remove-build-file "trivial.S"
180 foreach level {1 "" 3} {
181 if { ($type == "-gdwarf-2") && ($level != "") } {
182 lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
183 foreach opt $opt_opts {
184 lappend DEBUG_TORTURE_OPTIONS \
185 [list "${type}" "-g${level}" "$opt" ]
186 }
187 } else {
188 lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
189 foreach opt $opt_opts {
190 lappend DEBUG_TORTURE_OPTIONS \
191 [list "${type}${level}" "$opt" ]
192 }
193 }
194 }
195 }
196 }
197
198 verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
199
200 global runtests
201
202 foreach test $testcases {
203 # If we're only testing specific files and this isn't one of
204 # them, skip it.
205 if ![runtest_file_p $runtests $test] {
206 continue
207 }
208
209 set nshort [file tail [file dirname $test]]/[file tail $test]
210 list-module-names $test
211
212 foreach flags $DEBUG_TORTURE_OPTIONS {
213 set doit 1
214 # gcc-specific checking removed here
215
216 if { $doit } {
217 verbose -log "Testing $nshort, $flags" 1
218 dg-test $test $flags ""
219 cleanup-modules ""
220 }
221 }
222 }
223 }