OSDN Git Service

* lib/g++.exp (g++_init): Don't put { } around -fmessage-length=0.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / g++.exp
1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000 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/../g++ "$base_dir/../g++ -B$base_dir/../" [findfile $base_dir/g++ "$base_dir/g++ -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 ($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     }
129
130     if [info exists TOOL_OPTIONS] {
131         lappend ALWAYS_CXXFLAGS "additional_flags=$TOOL_OPTIONS";
132     }
133
134     # Make sure that lines are not wrapped.  That can confuse the
135     # error-message parsing machinery.
136     lappend ALWAYS_CXXFLAGS "additional_flags=-fmessage-length=0"
137
138     verbose -log "ALWAYS_CXXFLAGS set to $ALWAYS_CXXFLAGS"
139
140     verbose "g++ is initialized" 3
141 }
142
143
144 proc g++_target_compile { source dest type options } {
145     global tmpdir;
146     global gpp_compile_options
147     global gluefile wrap_flags
148     global ALWAYS_CXXFLAGS;
149     global GXX_UNDER_TEST;
150
151     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
152         lappend options "libs=${gluefile}"
153         lappend options "ldflags=${wrap_flags}"
154     }
155
156     lappend options "additional_flags=[libio_include_flags]"
157     lappend options "compiler=$GXX_UNDER_TEST";
158
159     set options [concat $gpp_compile_options $options]
160
161     set options [concat "$ALWAYS_CXXFLAGS" $options];
162
163     if { [regexp "(^| )-frepo( |$)" $options] && \
164          [regexp "\.o(|bj)$" $dest] } then {
165         regsub "\.o(|bj)$" $dest ".rpo" rponame
166         exec rm -f $rponame
167     }
168
169     return [target_compile $source $dest $type $options]
170 }
171
172 proc g++_exit { args } {
173     global gluefile;
174
175     if [info exists gluefile] {
176         file_on_build delete $gluefile;
177         unset gluefile;
178     }
179 }
180
181 # If this is an older version of dejagnu (without runtest_file_p),
182 # provide one and assume the old syntax: foo1.exp bar1.c foo2.exp bar2.c.
183 # This can be deleted after the next dejagnu release.
184
185 if { [info procs runtest_file_p] == "" } then {
186     proc runtest_file_p { runtests testcase } {
187         if { $runtests != "" && [regexp "\[.\]\[cC\]" $runtests] } then {
188             if { [lsearch $runtests [file tail $testcase]] >= 0 } then {
189                 return 1
190             } else {
191                 return 0
192             }
193         }
194         return 1
195     }
196 }
197
198 # Provide a definition of this if missing (delete after next dejagnu release).
199
200 if { [info procs prune_warnings] == "" } then {
201     proc prune_warnings { text } {
202         return $text
203     }
204 }
205
206 # Utility used by mike-g++.exp and old-dejagnu.exp.
207 # Check the compiler(/assembler/linker) output for text indicating that
208 # the testcase should be marked as "unsupported".
209 #
210 # When dealing with a large number of tests, it's difficult to weed out the
211 # ones that are too big for a particular cpu (eg: 16 bit with a small amount
212 # of memory).  There are various ways to deal with this.  Here's one.
213 # Fortunately, all of the cases where this is likely to happen will be using
214 # gld so we can tell what the error text will look like.
215
216 proc ${tool}_check_unsupported_p { output } {
217     if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $output] {
218         return "memory full"
219     }
220     return ""
221 }
222
223 proc ${tool}_option_help { } {
224     send_user "--additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated."
225 }
226
227 proc ${tool}_option_proc { option } {
228     if [regexp "^--additional_options," $option] {
229         global gpp_compile_options
230         regsub "--additional_options," $option "" option
231         foreach x [split $option ","] {
232             lappend gpp_compile_options "additional_flags=$x"
233         }
234         return 1;
235     } else {
236         return 0
237     }
238 }