1 # Copyright (C) 2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 proc dg-pch { subdir test options suffix } {
18 global runtests dg-do-what-default
20 # If we're only testing specific files and this isn't one of them, skip it.
21 if ![runtest_file_p $runtests $test] {
24 set nshort "$subdir/[file tail $test]"
25 set bname "[file rootname [file tail $nshort]]"
27 catch { file delete "$bname$suffix.gch" }
28 catch { file delete "$bname.s" }
29 catch { file delete "$bname.s-gch" }
31 # We don't try to use the loop-optimizing options, since they are highly
32 # unlikely to make any difference to PCH.
33 foreach flags $options {
34 verbose "Testing $nshort, $flags" 1
36 # For the header files, the default is to precompile.
37 set dg-do-what-default precompile
38 catch { file delete "$bname$suffix" }
39 file copy "[file rootname $test]${suffix}s" "$bname$suffix"
40 dg-test -keep-output "$bname$suffix" $flags ""
42 # For the rest, the default is to compile to .s.
43 set dg-do-what-default compile
45 if { [ file exists "$bname$suffix.gch" ] } {
46 # Ensure that the PCH file is used, not the original header.
47 file delete "$bname$suffix"
49 dg-test -keep-output $test $flags "-I."
50 file delete "$bname$suffix.gch"
51 if { [ file exists "$bname.s" ] } {
52 file rename "$bname.s" "$bname.s-gch"
53 file copy "[file rootname $test]${suffix}s" "$bname$suffix"
54 dg-test -keep-output $test $flags "-I."
55 set tmp [ diff "$bname.s" "$bname.s-gch" ]
57 untested "$nshort $flags assembly comparison"
58 } elseif { $tmp == 1 } {
59 pass "$nshort $flags assembly comparison"
61 fail "$nshort $flags assembly comparison"
63 file delete "$bname$suffix"
64 file delete "$bname.s"
65 file delete "$bname.s-gch"
67 untested "$nshort $flags assembly comparison"
71 untested "$nshort $flags"
72 untested "$nshort $flags assembly comparison"