OSDN Git Service

* gcc.dg/pragma-darwin.c: Improve for ppc64.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / gfortran-dg.exp
1 #   Copyright (C) 2004, 2005 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 2 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 this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
16
17 load_lib gcc-dg.exp
18
19 # Define gfortran callbacks for dg.exp.
20
21 proc gfortran-dg-test { prog do_what extra_tool_flags } {
22     set result \
23         [gcc-dg-test-1 gfortran_target_compile $prog $do_what $extra_tool_flags]
24     
25     set comp_output [lindex $result 0]
26     set output_file [lindex $result 1]
27
28     # gfortran error messages look like this:
29     #      In file [name]:[line]
30     #
31     #        some code
32     #              1
33     #     Error: Some error at (1) and (2)
34     # or
35     #      In file [name]:[line]
36     #
37     #       some code
38     #              1
39     #      In file [name]:[line2]
40     #
41     #       some other code
42     #         2
43     #     Error: Some error at (1) and (2)
44     # or
45     #      In file [name]:[line]
46     #
47     #       some code and some more code
48     #              1       2
49     #     Error: Some error at (1) and (2)
50     #
51     # We collapse these to look like:
52     #  [name]:[line]: Error: Some error at (1) and (2)
53     # or
54     #  [name]:[line]: Error: Some error at (1) and (2)
55     #  [name]:[line2]: Error: Some error at (1) and (2)
56     # We proceed in two steps: first we deal with the form with two
57     # different locus lines, then with the form with only one locus line.
58     #
59     # Note that these regexps only make sense in the combinations used below.
60     # Note also that is imperative that we first deal with the form with
61     # two loci.
62     set locus_regexp " In file (\[^\n\]*)\n\n\[^\n\]*\n\[^\n\]*\n"
63     set diag_regexp "(\[^\n\]*)\n"
64
65     set two_loci "$locus_regexp$locus_regexp$diag_regexp"
66     set single_locus "$locus_regexp$diag_regexp"
67     regsub -all $two_loci $comp_output "\\1: \\3\n\\2: \\3\n" comp_output
68     regsub -all $single_locus $comp_output "\\1: \\2\n" comp_output
69
70     return [list $comp_output $output_file]
71 }
72
73 proc gfortran-dg-prune { system text } {
74     return [gcc-dg-prune $system $text]
75 }
76
77 # Utility routines.
78
79 # Modified dg-runtest that can cycle through a list of optimization options
80 # as c-torture does.
81 proc gfortran-dg-runtest { testcases default-extra-flags } {
82     global runtests
83     global TORTURE_OPTIONS
84
85     foreach test $testcases {
86         # If we're only testing specific files and this isn't one of
87         # them, skip it.
88         if ![runtest_file_p $runtests $test] {
89             continue
90         }
91
92         # look if this is dg-do-run test, in which case
93         # we cycle through the option list, otherwise we don't
94         if [expr [search_for $test "dg-do run"]] {
95             set option_list $TORTURE_OPTIONS
96         } else {
97             set option_list [list { -O } ]
98         }
99
100         set nshort [file tail [file dirname $test]]/[file tail $test]
101
102         foreach flags $option_list {
103             verbose "Testing $nshort, $flags" 1
104             dg-test $test $flags ${default-extra-flags}
105         }
106     }
107 }