]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/lib/dg-pch.exp
Update copyright years in gcc/
[thirdparty/gcc.git] / gcc / testsuite / lib / dg-pch.exp
CommitLineData
23a5b65a 1# Copyright (C) 2003-2014 Free Software Foundation, Inc.
ac871ee1
MM
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
cd976c16 5# the Free Software Foundation; either version 3 of the License, or
ac871ee1
MM
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
cd976c16
NC
14# along with GCC; see the file COPYING3. If not see
15# <http://www.gnu.org/licenses/>.
ac871ee1 16
ccfc7360
L
17load_lib copy-file.exp
18
f6007d99
JJ
19proc pch-init { args } {
20 global pch_unsupported_debug pch_unsupported
21
22 if [info exists pch_unsupported_debug] {
23 error "pch-init: pch_unsupported_debug is not empty as expected"
24 }
25 if [info exists pch_unsupported] {
26 error "pch-init: pch_unsupported is not empty as expected"
27 }
28
29 set result [check_compile pchtest object "int i;" "-g -x c-header"]
30 set pch_unsupported_debug \
31 [regexp "debug format cannot be used with pre-compiled headers" \
32 [lindex $result 0]]
33
34 set pch_unsupported 0
35 if { $pch_unsupported_debug } {
36 verbose -log "pch is unsupported with the debug info format"
37
38 set result [check_compile pchtest object "int i;" "-x c-header"]
39 set pch_unsupported \
40 [regexp "debug format cannot be used with pre-compiled headers" \
41 [lindex $result 0]]
42 }
43}
44
45proc pch-finish { args } {
46 global pch_unsupported_debug pch_unsupported
47 unset pch_unsupported_debug
48 unset pch_unsupported
49}
50
51proc check_effective_target_pch_supported_debug { } {
52 global pch_unsupported_debug
53 if { $pch_unsupported_debug } {
54 return 0
55 }
56 return 1
57}
58
504d14c9 59proc dg-flags-pch { subdir test otherflags options suffix } {
ac871ee1 60 global runtests dg-do-what-default
f6007d99 61 global pch_unsupported_debug pch_unsupported
ac871ee1
MM
62
63 # If we're only testing specific files and this isn't one of them, skip it.
64 if ![runtest_file_p $runtests $test] {
ccc01444 65 return
ac871ee1 66 }
8c775844
DE
67
68 if { [istarget "powerpc-ibm-aix*"] } {
69 set torture_execute_xfail "powerpc-ibm-aix*"
70 return
71 }
72
ac871ee1
MM
73 set nshort "$subdir/[file tail $test]"
74 set bname "[file rootname [file tail $nshort]]"
75
485b51a7
MM
76 catch { file_on_host delete "$bname$suffix.gch" }
77 catch { file_on_host delete "$bname.s" }
78 catch { file_on_host delete "$bname.s-gch" }
ac871ee1
MM
79
80 # We don't try to use the loop-optimizing options, since they are highly
81 # unlikely to make any difference to PCH.
82 foreach flags $options {
504d14c9 83 verbose "Testing $nshort, $otherflags $flags" 1
ac871ee1 84
f6007d99
JJ
85 if { $pch_unsupported != 0 \
86 || ( $pch_unsupported_debug != 0 && [regexp " -g" " $flags"] ) } {
87 verbose -log "$nshort unsupported because debug format conflicts with PCH"
88 unsupported "$nshort $flags"
89 continue
90 }
91
ac871ee1
MM
92 # For the header files, the default is to precompile.
93 set dg-do-what-default precompile
485b51a7 94 catch { file_on_host delete "$bname$suffix" }
ccfc7360 95 gcc_copy_files "[file rootname $test]${suffix}s" "$bname$suffix"
504d14c9 96 dg-test -keep-output "./$bname$suffix" "$otherflags $flags" ""
ac871ee1
MM
97
98 # For the rest, the default is to compile to .s.
99 set dg-do-what-default compile
100
765f7c95
NS
101 set have_errs [llength [grep $test "{\[ \t\]\+dg-error\[ \t\]\+.*\[ \t\]\+}"]]
102
485b51a7 103 if { [ file_on_host exists "$bname$suffix.gch" ] } {
ac871ee1 104 # Ensure that the PCH file is used, not the original header.
485b51a7 105 file_on_host delete "$bname$suffix"
ac871ee1 106
8564f927
JJ
107 # The flags "-Dwith_PCH" and "-Dwithout_PCH" are to distinguish the
108 # two compiles in test summary lines.
109 dg-test -keep-output $test "$otherflags $flags -I. -Dwith_PCH" ""
485b51a7 110 file_on_host delete "$bname$suffix.gch"
765f7c95
NS
111 if { !$have_errs } {
112 if { [ file_on_host exists "$bname.s" ] } {
113 remote_upload host "$bname.s" "$bname.s-gch"
114 remote_download host "$bname.s-gch"
115 gcc_copy_files "[file rootname $test]${suffix}s" "$bname$suffix"
8564f927 116 dg-test -keep-output $test "$otherflags $flags -I. -Dwithout_PCH" ""
765f7c95
NS
117 remote_upload host "$bname.s"
118 set tmp [ diff "$bname.s" "$bname.s-gch" ]
119 if { $tmp == 0 } {
120 verbose -log "assembly file '$bname.s', '$bname.s-gch' comparison error"
504d14c9 121 fail "$nshort $otherflags $flags assembly comparison"
765f7c95 122 } elseif { $tmp == 1 } {
504d14c9 123 pass "$nshort $otherflags $flags assembly comparison"
765f7c95 124 } else {
504d14c9 125 fail "$nshort $otherflags $flags assembly comparison"
765f7c95
NS
126 }
127 file_on_host delete "$bname$suffix"
128 file_on_host delete "$bname.s"
129 file_on_host delete "$bname.s-gch"
ac871ee1 130 } else {
765f7c95
NS
131 verbose -log "assembly file '$bname.s' missing"
132 fail "$nshort $flags assembly comparison"
ac871ee1 133 }
6c9d8751 134 }
f6007d99
JJ
135 } elseif { $pch_unsupported_debug == 0 \
136 || [llength [grep $test "{\[ \t\]\+dg-require-effective-target\[ \t\]\+pch_supported_debug\[ \t\]\+.*\[ \t\]\+}"]] > 0 } {
6c9d8751
NS
137 verbose -log "pch file '$bname$suffix.gch' missing"
138 fail "$nshort $flags"
139 if { !$have_errs } {
140 verbose -log "assembly file '$bname.s' missing" 1
141 fail "$nshort $flags assembly comparison"
ac871ee1 142 }
ac871ee1
MM
143 }
144 }
145}
504d14c9
IS
146
147proc dg-pch { subdir test options suffix } {
148 return [dg-flags-pch $subdir $test "" $options $suffix]
8564f927 149}