No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / lib / target-supports-dg.exp
blobec7a3bd54ed8b1cf72e41dd31c0f0459a29da7ae
1 # Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
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.
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.
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.
17 # If this target does not support weak symbols, skip this test.
19 proc dg-require-weak { args } {
20 set weak_available [ check_weak_available ]
21 if { $weak_available == -1 } {
22 upvar name name
23 unresolved "$name"
25 if { $weak_available != 1 } {
26 upvar dg-do-what dg-do-what
27 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
31 # If this target does not support the "visibility" attribute, skip this
32 # test.
34 proc dg-require-visibility { args } {
35 set visibility_available [ check_visibility_available [lindex $args 1 ] ]
36 if { $visibility_available == -1 } {
37 upvar name name
38 unresolved "$name"
40 if { $visibility_available != 1 } {
41 upvar dg-do-what dg-do-what
42 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
46 # If this target does not support the "alias" attribute, skip this
47 # test.
49 proc dg-require-alias { args } {
50 set alias_available [ check_alias_available ]
51 if { $alias_available == -1 } {
52 upvar name name
53 unresolved "$name"
55 if { $alias_available < 2 } {
56 upvar dg-do-what dg-do-what
57 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
61 # If this target's linker does not support the --gc-sections flag,
62 # skip this test.
64 proc dg-require-gc-sections { args } {
65 if { ![ check_gc_sections_available ] } {
66 upvar dg-do-what dg-do-what
67 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
71 # If this target does not support profiling, skip this test.
73 proc dg-require-profiling { args } {
74 if { ![ check_profiling_available ${args} ] } {
75 upvar dg-do-what dg-do-what
76 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
80 # If this target does not support DLL attributes skip this test.
82 proc dg-require-dll { args } {
83 global target_triplet
84 # As a special case, the mcore-*-elf supports these attributes.
85 # All Symbian OS targets also support these attributes.
86 if { [string match "mcore-*-elf" $target_triplet]
87 || [string match "*-*-symbianelf" $target_triplet]} {
88 return
90 # PE/COFF targets support dllimport/dllexport.
91 if { [gcc_target_object_format] == "pe" } {
92 return
95 upvar dg-do-what dg-do-what
96 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
99 proc dg-require-iconv { args } {
100 if { ![ check_iconv_available ${args} ] } {
101 upvar dg-do-what dg-do-what
102 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
106 # If this target does not support named sections skip this test.
108 proc dg-require-named-sections { args } {
109 if { ![ check_named_sections_available ] } {
110 upvar dg-do-what dg-do-what
111 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
115 # If the target does not match the required effective target, skip this test.
117 proc dg-require-effective-target { args } {
118 set args [lreplace $args 0 0]
119 if { ![is-effective-target [lindex $args 0]] } {
120 upvar dg-do-what dg-do-what
121 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
125 # If this target does not have fork, skip this test.
127 proc dg-require-fork { args } {
128 if { ![check_fork_available] } {
129 upvar dg-do-what dg-do-what
130 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
134 # If this target does not have mkfifo, skip this test.
136 proc dg-require-mkfifo { args } {
137 if { ![check_mkfifo_available] } {
138 upvar dg-do-what dg-do-what
139 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
143 # Check the flags with which the test will be run against options in
144 # a test directive that will skip or xfail that test. The DejaGnu proc
145 # check_conditional_xfail will look at the options in compiler_flags, so
146 # set that up for this test based on flags we know about.
148 proc check_test_flags { args } {
149 global compiler_flags
150 upvar 2 dg-extra-tool-flags extra_tool_flags
152 # Pull the args out of the enclosing list.
153 set args [lindex $args 0]
155 # Start the list with a dummy tool name so the list will match "*"
156 # if there are no flags.
157 set compiler_flags " toolname "
158 append compiler_flags $extra_tool_flags
159 set dest [target_info name]
160 if [board_info $dest exists multilib_flags] {
161 append compiler_flags "[board_info $dest multilib_flags] "
164 set answer [check_conditional_xfail $args]
166 # Any value in this variable originally was left over from an earlier test.
167 set compiler_flags ""
169 verbose "check_test_flags: $args $answer" 2
170 return $answer
173 # Compare flags for a test directive against flags that will be used to
174 # compile the test: multilib flags, flags for torture options, and either
175 # the default flags for this group of tests or flags specified with a
176 # previous dg-options directive.
178 proc check-flags { args } {
179 global compiler_flags
180 global TOOL_OPTIONS
181 # These variables are from DejaGnu's dg-test.
182 upvar dg-extra-tool-flags extra_tool_flags
183 upvar tool_flags tool_flags
185 # The args are within another list; pull them out.
186 set args [lindex $args 0]
188 # Start the list with a dummy tool name so the list will match "*"
189 # if there are no flags.
190 set compiler_flags " toolname "
191 append compiler_flags $extra_tool_flags
192 append compiler_flags $tool_flags
193 # If running a subset of the test suite, $TOOL_OPTIONS may not exist.
194 catch {append compiler_flags " $TOOL_OPTIONS "}
195 set dest [target_info name]
196 if [board_info $dest exists multilib_flags] {
197 append compiler_flags "[board_info $dest multilib_flags] "
200 # The target list might be an effective-target keyword, so replace
201 # the original list with "*-*-*", since we already know it matches.
202 set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
204 # Any value in this variable was left over from an earlier test.
205 set compiler_flags ""
207 return $result
210 # Skip the test (report it as UNSUPPORTED) if the target list and
211 # included flags are matched and the excluded flags are not matched.
213 # The first argument is the line number of the dg-skip-if directive
214 # within the test file. Remaining arguments are as for xfail lists:
215 # message { targets } { include } { exclude }
217 # This tests against multilib flags plus either the default flags for this
218 # group of tests or flags specified with a previous dg-options command.
220 proc dg-skip-if { args } {
221 # Don't bother if we're already skipping the test.
222 upvar dg-do-what dg-do-what
223 if { [lindex ${dg-do-what} 1] == "N" } {
224 return
227 set args [lreplace $args 0 0]
229 set selector [list target [lindex $args 1]]
230 if { [dg-process-target $selector] == "S" } {
231 # These are defined in DejaGnu's dg-test, needed by check-flags.
232 upvar dg-extra-tool-flags dg-extra-tool-flags
233 upvar tool_flags tool_flags
235 if [check-flags $args] {
236 upvar dg-do-what dg-do-what
237 set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
242 # Like check_conditional_xfail, but callable from a dg test.
244 proc dg-xfail-if { args } {
245 # Don't change anything if we're already skipping the test.
246 upvar dg-do-what dg-do-what
247 if { [lindex ${dg-do-what} 1] == "N" } {
248 return
251 set args [lreplace $args 0 0]
252 set selector [list target [lindex $args 1]]
253 if { [dg-process-target $selector] == "S" } {
254 global compiler_conditional_xfail_data
255 set compiler_conditional_xfail_data [lreplace $args 1 1 "*-*-*"]
259 # Record whether the program is expected to return a nonzero status.
261 set shouldfail 0
263 proc dg-shouldfail { args } {
264 # Don't bother if we're already skipping the test.
265 upvar dg-do-what dg-do-what
266 if { [lindex ${dg-do-what} 1] == "N" } {
267 return
270 global shouldfail
272 set args [lreplace $args 0 0]
273 if { [llength $args] > 1 } {
274 set selector [list target [lindex $args 1]]
275 if { [dg-process-target $selector] == "S" } {
276 # The target matches, now check the flags. These variables
277 # are defined in DejaGnu's dg-test, needed by check-flags.
278 upvar dg-extra-tool-flags dg-extra-tool-flags
279 upvar tool_flags tool_flags
281 if [check-flags $args] {
282 set shouldfail 1
285 } else {
286 set shouldfail 1
290 # Intercept the call to the DejaGnu version of dg-process-target to
291 # support use of an effective-target keyword in place of a list of
292 # target triplets to xfail or skip a test.
294 # selector is one of:
295 # xfail target-triplet-1 ...
296 # xfail effective-target-keyword
297 # xfail selector-expression
298 # target target-triplet-1 ...
299 # target effective-target-keyword
300 # target selector-expression
302 # For a target list the result is "S" if the target is selected, "N" otherwise.
303 # For an xfail list the result is "F" if the target is affected, "P" otherwise.
305 # A selector expression appears within curly braces and uses a single logical
306 # operator: !, &&, or ||. An operand is another selector expression, an
307 # effective-target keyword, or a list of target triplets within quotes or
308 # curly braces.
310 if { [info procs saved-dg-process-target] == [list] } {
311 rename dg-process-target saved-dg-process-target
313 # Evaluate an operand within a selector expression.
314 proc selector_opd { op } {
315 set selector "target"
316 lappend selector $op
317 set answer [ expr { [dg-process-target $selector] == "S" } ]
318 verbose "selector_opd: `$op' $answer" 2
319 return $answer
322 # Evaluate a target triplet list within a selector expression.
323 # Unlike other operands, this needs to be expanded from a list to
324 # the same string as "target".
325 proc selector_list { op } {
326 set selector "target [join $op]"
327 set answer [ expr { [dg-process-target $selector] == "S" } ]
328 verbose "selector_list: `$op' $answer" 2
329 return $answer
332 # Evaluate a selector expression.
333 proc selector_expression { exp } {
334 if { [llength $exp] == 2 } {
335 if [string match "!" [lindex $exp 0]] {
336 set op1 [lindex $exp 1]
337 set answer [expr { ! [selector_opd $op1] }]
338 } else {
339 # Assume it's a list of target triplets.
340 set answer [selector_list $exp]
342 } elseif { [llength $exp] == 3 } {
343 set op1 [lindex $exp 0]
344 set opr [lindex $exp 1]
345 set op2 [lindex $exp 2]
346 if [string match "&&" $opr] {
347 set answer [expr { [selector_opd $op1] && [selector_opd $op2] }]
348 } elseif [string match "||" $opr] {
349 set answer [expr { [selector_opd $op1] || [selector_opd $op2] }]
350 } else {
351 # Assume it's a list of target triplets.
352 set answer [selector_list $exp]
354 } else {
355 # Assume it's a list of target triplets.
356 set answer [selector_list $exp]
359 verbose "selector_expression: `$exp' $answer" 2
360 return $answer
363 proc dg-process-target { args } {
364 verbose "replacement dg-process-target: `$args'" 2
366 # Extract the 'what' keyword from the argument list.
367 set selector [string trim [lindex $args 0]]
368 if [regexp "^xfail " $selector] {
369 set what "xfail"
370 } elseif [regexp "^target " $selector] {
371 set what "target"
372 } else {
373 error "syntax error in target selector \"$selector\""
376 # Extract the rest of the list, which might be a keyword.
377 regsub "^${what}" $selector "" rest
378 set rest [string trim $rest]
380 if [is-effective-target-keyword $rest] {
381 # The selector is an effective target keyword.
382 if [is-effective-target $rest] {
383 return [expr { $what == "xfail" ? "F" : "S" }]
384 } else {
385 return [expr { $what == "xfail" ? "P" : "N" }]
389 if [string match "{*}" $rest] {
390 if [selector_expression [lindex $rest 0]] {
391 return [expr { $what == "xfail" ? "F" : "S" }]
392 } else {
393 return [expr { $what == "xfail" ? "P" : "N" }]
397 # The selector is not an effective-target keyword, so process
398 # the list of target triplets.
399 return [saved-dg-process-target $selector]