blob: 5a16a39a4cd4fcfe5b26e360e00681f0f1e0bab7 [file] [log] [blame]
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
load_lib gcc-dg.exp
# Define gfortran callbacks for dg.exp.
proc gfortran-dg-test { prog do_what extra_tool_flags } {
set result \
[gcc-dg-test-1 gfortran_target_compile $prog $do_what $extra_tool_flags]
set comp_output [lindex $result 0]
set output_file [lindex $result 1]
# gfortran error messages look like this:
# [name]:[locus]:
#
# some code
# 1
# Error: Some error at (1)
# or
# [name]:[locus]:
#
# some code
# 1
# [name]:[locus2]:
#
# some other code
# 2
# Error: Some error at (1) and (2)
# or
# [name]:[locus]:
#
# some code and some more code
# 1 2
# Error: Some error at (1) and (2)
#
# Where [locus] is either [line] or [line].[columns] .
#
# We collapse these to look like:
# [name]:[line]: Error: Some error at (1) and (2)
# or
# [name]:[line]: Error: Some error at (1) and (2)
# [name]:[line2]: Error: Some error at (1) and (2)
# We proceed in two steps: first we deal with the form with two
# different locus lines, then with the form with only one locus line.
#
# Note that these regexps only make sense in the combinations used below.
# Note also that is imperative that we first deal with the form with
# two loci.
set locus_regexp "(\[^\n\]*):(\[0-9\]*)\[^\n\]*:\n\n\[^\n\]*\n\[^\n\]*\n"
set diag_regexp "(\[^\n\]*)\n"
set two_loci "$locus_regexp$locus_regexp$diag_regexp"
set single_locus "$locus_regexp$diag_regexp"
regsub -all $two_loci $comp_output "\\1:\\2: \\5\n\\3:\\4: \\5\n" comp_output
regsub -all $single_locus $comp_output "\\1:\\2: \\3\n" comp_output
return [list $comp_output $output_file]
}
proc gfortran-dg-prune { system text } {
return [gcc-dg-prune $system $text]
}
# Utility routines.
# Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does.
proc gfortran-dg-runtest { testcases default-extra-flags } {
global runtests
global TORTURE_OPTIONS
foreach test $testcases {
# If we're only testing specific files and this isn't one of
# them, skip it.
if ![runtest_file_p $runtests $test] {
continue
}
# look if this is dg-do-run test, in which case
# we cycle through the option list, otherwise we don't
if [expr [search_for $test "dg-do run"]] {
set option_list $TORTURE_OPTIONS
} else {
set option_list [list { -O } ]
}
set nshort [file tail [file dirname $test]]/[file tail $test]
foreach flags $option_list {
verbose "Testing $nshort, $flags" 1
dg-test $test $flags ${default-extra-flags}
}
}
}