OSDN Git Service

bf2dab4af908aed4a9b353522eb94edb3bb84ec5
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / pch / pch.exp
1 #   Copyright (C) 1997, 2002, 2003 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, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
16
17 # GCC testsuite for precompiled header interaction,
18 # that uses the `dg.exp' driver.
19
20 # Load support procs.
21 load_lib "g++-dg.exp"
22
23 # Initialize `dg'.
24 dg-init
25
26 set old_dg_do_what_default "${dg-do-what-default}"
27
28 # Main loop.
29 foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
30     global runtests dg-do-what-default
31
32     # If we're only testing specific files and this isn't one of them, skip it.
33     if ![runtest_file_p $runtests $test] {
34         continue
35     }
36     set nshort [file tail [file dirname $test]]/[file tail $test]
37     set bname "[file rootname [file tail $test]]"
38
39     catch { file delete "$bname.H.gch" }
40     catch { file delete "$bname.s" }
41     catch { file delete "$bname.s-gch" }
42
43     # We don't try to use the loop-optimizing options, since they are highly
44     # unlikely to make any difference to PCH.
45     foreach flags { "-g" "-O2 -g" "-O2" } {
46         verbose "Testing $nshort, $flags" 1
47
48         # For the header files, the default is to precompile.
49         set dg-do-what-default precompile
50         catch { file delete "$bname.H" }
51         file copy "[file rootname $test].Hs" "$bname.H"
52         dg-test -keep-output "$bname.H" $flags ""
53
54         # For the rest, the default is to compile to .s.
55         set dg-do-what-default compile
56
57         if { [ file exists "$bname.H.gch" ] } {
58             # Ensure that the PCH file is used, not the original header.
59             file delete "$bname.H"
60
61             dg-test -keep-output $test $flags "-I."
62             file delete "$bname.H.gch"
63             if { [ file exists "$bname.s" ] } {
64                 file rename "$bname.s" "$bname.s-gch"
65                 file copy "[file rootname $test].Hs" "$bname.H"
66                 dg-test -keep-output $test $flags "-I."
67                 set tmp [ diff "$bname.s" "$bname.s-gch" ]
68                 if { $tmp == 0 } {
69                     untested "$nshort $flags assembly comparison"
70                 } elseif { $tmp == 1 } {
71                     pass "$nshort $flags assembly comparison"
72                 } else {
73                     fail "$nshort $flags assembly comparison"
74                 }
75                 file delete "$bname.H"
76                 file delete "$bname.s"
77                 file delete "$bname.s-gch"
78             } else {
79                 untested "$nshort $flags assembly comparison"
80             }
81
82         } else {
83             untested $nshort
84             untested "$nshort $flags assembly comparison"
85         }
86     }
87 }
88
89 set dg-do-what-default "$old_dg_do_what_default"
90
91 # All done.
92 dg-finish