This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PCH] testsuite
- From: Geoffrey Keating <geoffk at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Aug 2002 15:53:42 -0700
- Subject: [PCH] testsuite
This adds the beginnings of a testsuite for precompiled headers,
and fixes a few bugs I noticed while adding the tests.
I haven't added a special objc testsuite, I hope there won't be any
bugs there that aren't also in C :-).
I'll commit when the bootstrap & test on x86-linux completes.
Note that the diff does include two completely empty files.
--
Geoff Keating <geoffk@redhat.com>
===File ~/patches/pch-testsuite.patch=======================
Index: ChangeLog
2002-08-27 Geoffrey Keating <geoffk@redhat.com>
* c-pch.c (c_common_write_pch): Rename from c_write_pch, change
callers.
(c_common_valid_pch): Rename from c_valid_pch, change callers.
(c_common_read_pch): Rename from c_read_pch, change callers.
* c-opts.c (COMMAND_LINE_OPTIONS): Allow -output-pch= to have
a space between it and its argument.
Index: cp/ChangeLog
2002-08-27 Geoffrey Keating <geoffk@redhat.com>
* decl2.c (finish_file): Call c_common_write_pch.
* Make-lang.in (CXX_C_OBJS): Add c-pch.o.
Index: testsuite/ChangeLog
2002-08-27 Geoffrey Keating <geoffk@redhat.com>
* g++.dg/dg.exp: Treat files in pch/ specially.
* g++.dg/pch/pch.exp: New file.
* g++.dg/pch/empty.H: New file.
* g++.dg/pch/empty.C: New file.
* lib/g++-dg.exp (g++-dg-test): Add case for when $do_what is
"precompile".
* gcc.dg/pch/pch.exp: New file.
* gcc.dg/pch/empty.h: New file.
* gcc.dg/pch/empty.c: New file.
* lib/gcc-dg.exp (gcc-dg-test): Add case for when $do_what is
"precompile".
Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.112.4.14
diff -p -u -p -r1.112.4.14 c-common.h
--- c-common.h 25 Aug 2002 00:47:57 -0000 1.112.4.14
+++ c-common.h 27 Aug 2002 22:48:26 -0000
@@ -1239,11 +1239,11 @@ extern void dump_time_statistics PARAMS
extern int c_dump_tree PARAMS ((void *, tree));
extern void pch_init PARAMS ((void));
-extern int c_valid_pch PARAMS ((cpp_reader *pfile,
+extern int c_common_valid_pch PARAMS ((cpp_reader *pfile,
const char *name,
int fd));
-extern void c_read_pch PARAMS ((cpp_reader *pfile,
+extern void c_common_read_pch PARAMS ((cpp_reader *pfile,
int fd));
-extern void c_write_pch PARAMS ((void));
+extern void c_common_write_pch PARAMS ((void));
#endif /* ! GCC_C_COMMON_H */
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.163.4.7
diff -p -u -p -r1.163.4.7 c-lex.c
--- c-lex.c 25 Aug 2002 00:47:57 -0000 1.163.4.7
+++ c-lex.c 27 Aug 2002 22:48:27 -0000
@@ -122,8 +122,8 @@ init_c_lex (filename)
cb->ident = cb_ident;
cb->file_change = cb_file_change;
cb->def_pragma = cb_def_pragma;
- cb->valid_pch = c_valid_pch;
- cb->read_pch = c_read_pch;
+ cb->valid_pch = c_common_valid_pch;
+ cb->read_pch = c_common_read_pch;
/* Set the debug callbacks if we can use them. */
if (debug_info_level == DINFO_LEVEL_VERBOSE
Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.2.6.7
diff -p -u -p -r1.2.6.7 c-objc-common.c
--- c-objc-common.c 25 Aug 2002 00:47:57 -0000 1.2.6.7
+++ c-objc-common.c 27 Aug 2002 22:48:27 -0000
@@ -345,7 +345,7 @@ c_objc_common_finish_file ()
expand_deferred_fns ();
if (pch_file)
- c_write_pch ();
+ c_common_write_pch ();
if (static_ctors)
{
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.10.2.3
diff -p -u -p -r1.10.2.3 c-opts.c
--- c-opts.c 25 Aug 2002 00:47:57 -0000 1.10.2.3
+++ c-opts.c 27 Aug 2002 22:48:27 -0000
@@ -79,7 +79,7 @@ static void handle_OPT_d PARAMS ((const
#define COMMAND_LINE_OPTIONS \
OPT("-help", CL_ALL, OPT__help) \
- OPT("-output-pch=", CL_ALL | CL_JOINED, OPT__output_pch) \
+ OPT("-output-pch=", CL_ALL | CL_ARG, OPT__output_pch) \
OPT("C", CL_ALL, OPT_C) \
OPT("CC", CL_ALL, OPT_CC) \
OPT("E", CL_ALL, OPT_E) \
Index: c-pch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-pch.c,v
retrieving revision 1.1.2.1
diff -p -u -p -r1.1.2.1 c-pch.c
--- c-pch.c 25 Aug 2002 00:47:57 -0000 1.1.2.1
+++ c-pch.c 27 Aug 2002 22:48:27 -0000
@@ -79,7 +79,7 @@ pch_init ()
}
void
-c_write_pch ()
+c_common_write_pch ()
{
char *buf;
off_t asm_file_end;
@@ -119,7 +119,7 @@ c_write_pch ()
}
int
-c_valid_pch (pfile, name, fd)
+c_common_valid_pch (pfile, name, fd)
cpp_reader *pfile;
const char *name;
int fd;
@@ -169,7 +169,7 @@ c_valid_pch (pfile, name, fd)
}
void
-c_read_pch (pfile, fd)
+c_common_read_pch (pfile, fd)
cpp_reader *pfile;
int fd;
{
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.103.6.13
diff -p -u -p -r1.103.6.13 Make-lang.in
--- cp/Make-lang.in 13 Aug 2002 17:57:30 -0000 1.103.6.13
+++ cp/Make-lang.in 27 Aug 2002 22:48:29 -0000
@@ -96,7 +96,7 @@ $(DEMANGLER_PROG): cxxmain.o underscore.
# The compiler itself.
# Shared with C front end:
CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \
- c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o
+ c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o
# Language-specific object files.
CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.512.2.10
diff -p -u -p -r1.512.2.10 decl2.c
--- cp/decl2.c 13 Aug 2002 17:57:36 -0000 1.512.2.10
+++ cp/decl2.c 27 Aug 2002 22:48:29 -0000
@@ -2736,6 +2736,9 @@ finish_file ()
if (! global_bindings_p () || current_class_type || decl_namespace_list)
return;
+ if (pch_file)
+ c_common_write_pch ();
+
/* Otherwise, GDB can get confused, because in only knows
about source for LINENO-1 lines. */
lineno -= 1;
Index: testsuite/g++.dg/dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/dg.exp,v
retrieving revision 1.3.12.3
diff -p -u -p -r1.3.12.3 dg.exp
--- testsuite/g++.dg/dg.exp 24 Jun 2002 23:28:09 -0000 1.3.12.3
+++ testsuite/g++.dg/dg.exp 27 Aug 2002 22:48:31 -0000
@@ -34,6 +34,7 @@ set tests [lsort [find $srcdir/$subdir *
set tests [prune $tests $srcdir/$subdir/bprob/*]
set tests [prune $tests $srcdir/$subdir/debug/*]
set tests [prune $tests $srcdir/$subdir/gcov/*]
+set tests [prune $tests $srcdir/$subdir/pch/*]
set tests [prune $tests $srcdir/$subdir/special/*]
set tests [prune $tests $srcdir/$subdir/tls/*]
Index: testsuite/g++.dg/pch/empty.C
===================================================================
RCS file: testsuite/g++.dg/pch/empty.C
diff -N testsuite/g++.dg/pch/empty.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/pch/empty.C 27 Aug 2002 22:48:31 -0000
@@ -0,0 +1,5 @@
+#include "empty.Hp"
+int main()
+{
+ return 0;
+}
Index: testsuite/g++.dg/pch/empty.H
===================================================================
RCS file: testsuite/g++.dg/pch/empty.H
diff -N testsuite/g++.dg/pch/empty.H
Index: testsuite/g++.dg/pch/pch.exp
===================================================================
RCS file: testsuite/g++.dg/pch/pch.exp
diff -N testsuite/g++.dg/pch/pch.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/pch/pch.exp 27 Aug 2002 22:48:31 -0000
@@ -0,0 +1,59 @@
+# Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# GCC testsuite for precompiled header interaction,
+# that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib "g++-dg.exp"
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] {
+ global runtests torture_without_loops dg-do-what-default
+
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $test] {
+ continue
+ }
+ set nshort [file tail [file dirname $test]]/[file tail $test]
+ set bname "[file rootname [file tail $test]]"
+
+ verbose "Testing $nshort" 1
+
+ # For the header files, the default is to precompile.
+ set old_dg_do_what_default "${dg-do-what-default}"
+ set dg-do-what-default precompile
+ dg-test -keep-output "[file rootname $test].H" "" ""
+ set dg-do-what-default "$old_dg_do_what_default"
+
+ # To ensure that the PCH is used, not the original header,
+ # the actual PCH file is renamed to "<foo>.Hp.pch".
+ if { [ is_remote host ] } {
+ remote_upload host "$bname.H.pch" "$bname.Hp.pch"
+ file_on_host delete "$bname.H.pch"
+ remote_download host "$bname.Hp.pch"
+ } else {
+ file rename "$bname.H.pch" "$bname.Hp.pch"
+ }
+ dg-test $test "" "-I."
+ file delete "$bname.Hp.pch"
+}
+
+# All done.
+dg-finish
Index: testsuite/gcc.dg/pch/empty.c
===================================================================
RCS file: testsuite/gcc.dg/pch/empty.c
diff -N testsuite/gcc.dg/pch/empty.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/pch/empty.c 27 Aug 2002 22:48:32 -0000
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+
+/* Yes, it's called "empty" because it has no contents at all.
+ Even this comment goes here, rather than in empty.h. */
+#include "empty.hp"
+
+int main(void)
+{
+ return 0;
+}
Index: testsuite/gcc.dg/pch/empty.h
===================================================================
RCS file: testsuite/gcc.dg/pch/empty.h
diff -N testsuite/gcc.dg/pch/empty.h
Index: testsuite/gcc.dg/pch/pch.exp
===================================================================
RCS file: testsuite/gcc.dg/pch/pch.exp
diff -N testsuite/gcc.dg/pch/pch.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/pch/pch.exp 27 Aug 2002 22:48:32 -0000
@@ -0,0 +1,63 @@
+# Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# GCC testsuite for precompiled header interaction,
+# that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
+ global runtests torture_without_loops dg-do-what-default
+
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $test] {
+ continue
+ }
+ set nshort [file tail [file dirname $test]]/[file tail $test]
+ set bname "[file rootname [file tail $test]]"
+
+ # We don't try to use the loop-optimizing options, since they are highly
+ # unlikely to make any difference to PCH.
+ foreach flags $torture_without_loops {
+ verbose "Testing $nshort, $flags" 1
+
+ # For the header files, the default is to precompile.
+ set old_dg_do_what_default "${dg-do-what-default}"
+ set dg-do-what-default precompile
+ dg-test -keep-output "[file rootname $test].h" $flags ""
+ set dg-do-what-default "$old_dg_do_what_default"
+
+ # To ensure that the PCH is used, not the original header,
+ # the actual PCH file is renamed to "<foo>.hp.pch".
+ if { [ is_remote host ] } {
+ remote_upload host "$bname.h.pch" "$bname.hp.pch"
+ file_on_host delete "$bname.h.pch"
+ remote_download host "$bname.hp.pch"
+ } else {
+ file rename "$bname.h.pch" "$bname.hp.pch"
+ }
+ dg-test $test $flags "-I."
+ file delete "$bname.hp.pch"
+ }
+}
+
+# All done.
+dg-finish
Index: testsuite/lib/g++-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/g++-dg.exp,v
retrieving revision 1.5.14.1
diff -p -u -p -r1.5.14.1 g++-dg.exp
--- testsuite/lib/g++-dg.exp 13 Feb 2002 23:37:34 -0000 1.5.14.1
+++ testsuite/lib/g++-dg.exp 27 Aug 2002 22:48:33 -0000
@@ -37,6 +37,10 @@ proc g++-dg-test { prog do_what extra_to
set compile_type "object"
set output_file "[file rootname [file tail $prog]].o"
}
+ "precompile" {
+ set compile_type "precompiled_header"
+ set output_file "[file tail $prog].pch"
+ }
"link" {
set compile_type "executable"
set output_file "[file rootname [file tail $prog]].exe"
Index: testsuite/lib/gcc-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/lib/gcc-dg.exp,v
retrieving revision 1.10.14.1
diff -p -u -p -r1.10.14.1 gcc-dg.exp
--- testsuite/lib/gcc-dg.exp 13 Feb 2002 23:37:34 -0000 1.10.14.1
+++ testsuite/lib/gcc-dg.exp 27 Aug 2002 22:48:33 -0000
@@ -69,6 +69,10 @@ proc gcc-dg-test { prog do_what extra_to
set compile_type "object"
set output_file "[file rootname [file tail $prog]].o"
}
+ "precompile" {
+ set compile_type "precompiled_header"
+ set output_file "[file tail $prog].pch"
+ }
"link" {
set compile_type "executable"
set output_file "[file rootname [file tail $prog]].exe"
============================================================