OSDN Git Service

* lib/old-dejagnu.exp (old-dejagnu): ignore collect recompiling
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / g++.exp
1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-g++@prep.ai.mit.edu
19
20 # This file was written by Rob Savoye (rob@cygnus.com)
21 # Many modifications by Jeffrey Wheat (cassidy@cygnus.com)
22 # With modifications by Mike Stump <mrs@cygnus.com>.
23
24 #
25 # g++ support library routines
26 #
27
28 #
29 # GXX_UNDER_TEST is the compiler under test.
30 #
31
32
33 set gpp_compile_options ""
34
35 #
36 # g++_version -- extract and print the version number of the compiler
37 #
38 proc g++_version { } {
39     global GXX_UNDER_TEST
40     
41     # ignore any arguments after the command
42     set compiler [lindex $GXX_UNDER_TEST 0]
43     
44     # verify that the compiler exists
45     if { [is_remote host] || [which $compiler] != 0 } then {
46         set tmp [remote_exec host "$compiler -v"]
47         set status [lindex $tmp 0];
48         set output [lindex $tmp 1];
49         regexp "version.*$" $output version
50         if { $status == 0 && [info exists version] } then {
51             if [is_remote host] {
52                 clone_output "$compiler $version\n"
53             } else {
54                 clone_output "[which $compiler] $version\n"
55             }
56         } else {
57             clone_output "Couldn't determine version of [which $compiler]\n"
58         }
59     } else {
60         # compiler does not exist (this should have already been detected)
61         warning "$compiler does not exist"
62     }
63 }
64
65 #
66 # g++_init -- called at the start of each subdir of tests
67 #
68
69 proc g++_init { args } {
70     global subdir
71     global gpp_initialized
72     global base_dir
73     global tmpdir
74     global libdir
75     global gluefile wrap_flags;
76     global objdir srcdir
77     global ALWAYS_CXXFLAGS
78     global TOOL_EXECUTABLE TOOL_OPTIONS
79     global GXX_UNDER_TEST
80
81     if ![info exists GXX_UNDER_TEST] then {
82         if [info exists TOOL_EXECUTABLE] {
83             set GXX_UNDER_TEST $TOOL_EXECUTABLE;
84         } else {
85             if [is_remote host] {
86                 set GXX_UNDER_TEST [transform c++]
87             } else {
88                 set GXX_UNDER_TEST [findfile $base_dir/../xgcc "$base_dir/../xgcc -B$base_dir/../" [findfile $base_dir/xgcc "$base_dir/xgcc -B$base_dir/" [transform c++]]]
89             }
90         }
91     }
92
93     # Bleah, nasty. Bad taste.
94     if [ishost "*-dos-*" ] {
95         regsub "c\\+\\+" "$GXX_UNDER_TEST" "gcc" GXX_UNDER_TEST
96     }
97
98     if ![is_remote host] {
99         if { [which $GXX_UNDER_TEST] == 0 } then {
100             perror "GXX_UNDER_TEST does not exist"
101             exit 1
102         }
103     }
104     if ![info exists tmpdir] {
105         set tmpdir "/tmp"
106     }
107
108     if [info exists gluefile] {
109         unset gluefile
110     }
111
112     if { [target_info needs_status_wrapper] != "" } {
113         set gluefile ${tmpdir}/testglue.o;
114         set result [build_wrapper $gluefile];
115         if { $result != "" } {
116             set gluefile [lindex $result 0];
117             set wrap_flags [lindex $result 1];
118         } else {
119             unset gluefile
120         }
121     }
122
123     set ALWAYS_CXXFLAGS ""
124
125     if ![is_remote host] {
126         lappend ALWAYS_CXXFLAGS "additional_flags=[g++_include_flags]";
127         lappend ALWAYS_CXXFLAGS "ldflags=[g++_link_flags]";
128         lappend ALWAYS_CXXFLAGS "incdir=$base_dir/../include"
129     }
130
131     if [info exists TOOL_OPTIONS] {
132         lappend ALWAYS_CXXFLAGS "additional_flags=$TOOL_OPTIONS";
133     }
134
135     verbose -log "ALWAYS_CXXFLAGS set to $ALWAYS_CXXFLAGS"
136
137     verbose "g++ is initialized" 3
138 }
139
140
141 proc g++_target_compile { source dest type options } {
142     global tmpdir;
143     global gpp_compile_options
144     global gluefile wrap_flags
145     global ALWAYS_CXXFLAGS;
146     global GXX_UNDER_TEST;
147
148     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
149         lappend options "libs=${gluefile}"
150         lappend options "ldflags=${wrap_flags}"
151     }
152
153     lappend options "additional_flags=[libio_include_flags]"
154     lappend options "compiler=$GXX_UNDER_TEST";
155
156     set options [concat $options $gpp_compile_options]
157
158     set options [concat $options "$ALWAYS_CXXFLAGS"];
159
160     if { [regexp "(^| )-frepo( |$)" $options] && \
161          [regexp "\.o(|bj)$" $dest] } then {
162         regsub "\.o(|bj)$" $dest ".rpo" rponame
163         exec rm -f $rponame
164     }
165
166     return [target_compile $source $dest $type $options]
167 }
168
169 proc g++_exit { args } {
170     global gluefile;
171
172     if [info exists gluefile] {
173         file_on_build delete $gluefile;
174         unset gluefile;
175     }
176 }
177
178 # If this is an older version of dejagnu (without runtest_file_p),
179 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
180 # This can be deleted after the next dejagnu release.
181
182 if { [info procs runtest_file_p] == "" } then {
183     proc runtest_file_p { runtests testcase } {
184         if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
185             if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
186                 return 1
187             } else {
188                 return 0
189             }
190         }
191         return 1
192     }
193 }
194
195 # Provide a definition of this if missing (delete after next dejagnu release).
196
197 if { [info procs prune_warnings] == "" } then {
198     proc prune_warnings { text } {
199         return $text
200     }
201 }
202
203 # Utility used by mike-g++.exp and old-dejagnu.exp.
204 # Check the compiler(/assembler/linker) output for text indicating that
205 # the testcase should be marked as "unsupported".
206 #
207 # When dealing with a large number of tests, it's difficult to weed out the
208 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
209 # of memory).  There are various ways to deal with this.  Here's one.
210 # Fortunately, all of the cases where this is likely to happen will be using
211 # gld so we can tell what the error text will look like.
212
213 proc ${tool}_check_unsupported_p { output } {
214     if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
215         return "memory full"
216     }
217     return ""
218 }
219
220 proc ${tool}_option_help { } {
221     send_user "--additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated."
222 }
223
224 proc ${tool}_option_proc { option } {
225     if[regexp "^--additional_options," $option] {
226         global gpp_compile_options
227         regsub "--additional_options," $option "" option
228         foreach x [split $option ","] {
229             lappend gpp_compile_options "additional_flags=$x"
230         }
231         return 1;
232     } else {
233         return 0
234     }
235 }