1 |
701 |
jeremybenn |
# Copyright (C) 2004, 2005, 2006, 2007, 2008 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 |
|
|
# .
|
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 |
|
|
# gfortran error messages look like this:
|
30 |
|
|
# [name]:[locus]:
|
31 |
|
|
#
|
32 |
|
|
# some code
|
33 |
|
|
# 1
|
34 |
|
|
# Error: Some error at (1)
|
35 |
|
|
# or
|
36 |
|
|
# [name]:[locus]:
|
37 |
|
|
#
|
38 |
|
|
# some code
|
39 |
|
|
# 1
|
40 |
|
|
# [name]:[locus2]:
|
41 |
|
|
#
|
42 |
|
|
# some other code
|
43 |
|
|
# 2
|
44 |
|
|
# Error: Some error at (1) and (2)
|
45 |
|
|
# or
|
46 |
|
|
# [name]:[locus]:
|
47 |
|
|
#
|
48 |
|
|
# some code and some more code
|
49 |
|
|
# 1 2
|
50 |
|
|
# Error: Some error at (1) and (2)
|
51 |
|
|
#
|
52 |
|
|
# Where [locus] is either [line] or [line].[columns] .
|
53 |
|
|
#
|
54 |
|
|
# We collapse these to look like:
|
55 |
|
|
# [name]:[line]:[column]: Error: Some error at (1) and (2)
|
56 |
|
|
# or
|
57 |
|
|
# [name]:[line]:[column]: Error: Some error at (1) and (2)
|
58 |
|
|
# [name]:[line2]:[column]: 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.
|
61 |
|
|
#
|
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
|
64 |
|
|
# two loci.
|
65 |
|
|
set locus_regexp "(\[^\n\]*):(\[0-9\]+)\[\.:\](\[0-9\]*)(-\[0-9\]*)?:\n\n\[^\n\]*\n\[^\n\]*\n"
|
66 |
|
|
set diag_regexp "(\[^\n\]*)\n"
|
67 |
|
|
|
68 |
|
|
# Add column number if none exists
|
69 |
|
|
set colnum_regexp "(Warning: |Error: )?(\[^\n\]*):(\[0-9\]+):(\[ \n\])"
|
70 |
|
|
regsub -all $colnum_regexp $comp_output "\\2:\\3:0:\\4\\1" comp_output
|
71 |
|
|
|
72 |
|
|
set two_loci "$locus_regexp$locus_regexp$diag_regexp"
|
73 |
|
|
set single_locus "$locus_regexp$diag_regexp"
|
74 |
|
|
regsub -all $two_loci $comp_output "\\1:\\2:\\3: \\9\n\\5:\\6:\\7: \\9\n" comp_output
|
75 |
|
|
regsub -all $single_locus $comp_output "\\1:\\2:\\3: \\5\n" comp_output
|
76 |
|
|
|
77 |
|
|
# Add a line number if none exists
|
78 |
|
|
regsub -all "(^|\n)(Warning: |Error: )" $comp_output "\\1:0:0: \\2" comp_output
|
79 |
|
|
|
80 |
|
|
return [list $comp_output $output_file]
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
proc gfortran-dg-prune { system text } {
|
84 |
|
|
return [gcc-dg-prune $system $text]
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
# Utility routines.
|
88 |
|
|
|
89 |
|
|
# Modified dg-runtest that can cycle through a list of optimization options
|
90 |
|
|
# as c-torture does.
|
91 |
|
|
proc gfortran-dg-runtest { testcases default-extra-flags } {
|
92 |
|
|
global runtests
|
93 |
|
|
global DG_TORTURE_OPTIONS torture_with_loops
|
94 |
|
|
|
95 |
|
|
torture-init
|
96 |
|
|
set-torture-options $DG_TORTURE_OPTIONS
|
97 |
|
|
|
98 |
|
|
foreach test $testcases {
|
99 |
|
|
# If we're only testing specific files and this isn't one of
|
100 |
|
|
# them, skip it.
|
101 |
|
|
if ![runtest_file_p $runtests $test] {
|
102 |
|
|
continue
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
# look if this is dg-do-run test, in which case
|
106 |
|
|
# we cycle through the option list, otherwise we don't
|
107 |
|
|
if [expr [search_for $test "dg-do run"]] {
|
108 |
|
|
set option_list $torture_with_loops
|
109 |
|
|
} else {
|
110 |
|
|
set option_list [list { -O } ]
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
set nshort [file tail [file dirname $test]]/[file tail $test]
|
114 |
|
|
|
115 |
|
|
foreach flags $option_list {
|
116 |
|
|
verbose "Testing $nshort, $flags" 1
|
117 |
|
|
dg-test $test $flags ${default-extra-flags}
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
torture-finish
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
proc gfortran-dg-debug-runtest { target_compile trivial opt_opts testcases } {
|
125 |
|
|
global srcdir subdir DEBUG_TORTURE_OPTIONS
|
126 |
|
|
|
127 |
|
|
if ![info exists DEBUG_TORTURE_OPTIONS] {
|
128 |
|
|
set DEBUG_TORTURE_OPTIONS ""
|
129 |
|
|
set type_list [list "-gstabs" "-gstabs+" "-gxcoff" "-gxcoff+" "-gcoff" "-gdwarf-2" ]
|
130 |
|
|
foreach type $type_list {
|
131 |
|
|
set comp_output [$target_compile \
|
132 |
|
|
"$srcdir/$subdir/$trivial" "trivial.S" assembly \
|
133 |
|
|
"additional_flags=$type"]
|
134 |
|
|
if { [string match "exit status *" $comp_output] } {
|
135 |
|
|
continue
|
136 |
|
|
}
|
137 |
|
|
if { [string match \
|
138 |
|
|
"* target system does not support the * debug format*" \
|
139 |
|
|
$comp_output]
|
140 |
|
|
} {
|
141 |
|
|
continue
|
142 |
|
|
}
|
143 |
|
|
remove-build-file "trivial.S"
|
144 |
|
|
foreach level {1 "" 3} {
|
145 |
|
|
if { ($type == "-gdwarf-2") && ($level != "") } {
|
146 |
|
|
lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
|
147 |
|
|
foreach opt $opt_opts {
|
148 |
|
|
lappend DEBUG_TORTURE_OPTIONS \
|
149 |
|
|
[list "${type}" "-g${level}" "$opt" ]
|
150 |
|
|
}
|
151 |
|
|
} else {
|
152 |
|
|
lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
|
153 |
|
|
foreach opt $opt_opts {
|
154 |
|
|
lappend DEBUG_TORTURE_OPTIONS \
|
155 |
|
|
[list "${type}${level}" "$opt" ]
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
}
|
159 |
|
|
}
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
|
163 |
|
|
|
164 |
|
|
global runtests
|
165 |
|
|
|
166 |
|
|
foreach test $testcases {
|
167 |
|
|
# If we're only testing specific files and this isn't one of
|
168 |
|
|
# them, skip it.
|
169 |
|
|
if ![runtest_file_p $runtests $test] {
|
170 |
|
|
continue
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
set nshort [file tail [file dirname $test]]/[file tail $test]
|
174 |
|
|
|
175 |
|
|
foreach flags $DEBUG_TORTURE_OPTIONS {
|
176 |
|
|
set doit 1
|
177 |
|
|
# gcc-specific checking removed here
|
178 |
|
|
|
179 |
|
|
if { $doit } {
|
180 |
|
|
verbose -log "Testing $nshort, $flags" 1
|
181 |
|
|
dg-test $test $flags ""
|
182 |
|
|
}
|
183 |
|
|
}
|
184 |
|
|
}
|
185 |
|
|
}
|