1 # Copyright
(C
) 2009-2017 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
3 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 GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
17 # We
set LC_ALL and LANG to C so that we
get the same error messages as expected.
21 # Many hosts now default to a non
-ASCII C locale
, however
, so
22 # they can
set a
charset encoding here
if they need.
23 if { [ishost
"*-*-cygwin*"] } {
28 # Run the LANGUAGE compiler with GCC_OPTIONS and inspect the compiler
29 # output to make sure that they match the newline
-separated patterns
30 # in COMPILER_PATTERNS but not the patterns in COMPILER_NON_PATTERNS.
31 # In case of failure
, xfail
if XFAIL is nonempty.
33 proc check_for_options
{language gcc_options compiler_patterns compiler_non_patterns expected_failure
} {
34 set filename test
-[pid
]
35 set fd
[open $filename.c w
]
36 puts $fd
"int main (void) { return 0; }"
38 remote_download host $filename.c
40 set test
"compiler driver $gcc_options option(s):"
41 set gcc_options
"\{additional_flags=$gcc_options\}"
44 "c" { set compiler cc1 }
45 default
{ error
"unknown language" }
47 set gcc_output
[gcc_target_compile $filename.c $filename.x executable $gcc_options
]
48 remote_file build
delete $filename.c $filename.x $filename.gcno
50 # Verify that COMPILER_PATTERRNS appear in gcc output.
51 foreach pattern
[split $compiler_patterns
"\n"] {
53 if {[regexp
-line
-- "$pattern" $gcc_output]} {
56 if {$expected_failure
!= ""} {
57 xfail
"$test \"$pattern\" present in output"
59 fail
"$test \"$pattern\" present in output"
65 # Verify that COMPILER_NON_PATTERRNS
do not appear in gcc output.
66 foreach pattern
[split $compiler_non_patterns
"\n"] {
68 if {![regexp
-line
-- "$pattern" $gcc_output result]} {
71 if {$expected_failure
!= ""} {
72 xfail
"$test \"$pattern\" absent from output"
74 # Print the unexpected line that caused the failure
75 # to make it easier to find in the multiline output.
76 fail
"$test \"$pattern\" absent from output: \"$result\""