diff options
author | Geoffrey Keating <geoffk@gcc.gnu.org> | 2003-01-10 02:22:34 +0000 |
---|---|---|
committer | Geoffrey Keating <geoffk@gcc.gnu.org> | 2003-01-10 02:22:34 +0000 |
commit | 17211ab55314d76370a68036f2d057b1effd687f (patch) | |
tree | a3ff2e89f1924fd7ea1d99358736bc8491352747 /gcc/testsuite | |
parent | 5f7c78d8a4df096dacfa2d9de367a6174dd631ba (diff) | |
download | gcc-17211ab55314d76370a68036f2d057b1effd687f.tar.gz |
Merge from pch-branch.
From-SVN: r61136
Diffstat (limited to 'gcc/testsuite')
48 files changed, 477 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8168b989ade..e1c6e0287ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,87 @@ +2003-01-09 Geoffrey Keating <geoffk@apple.com> + + Merge from pch-branch: + + 2002-12-23 Geoffrey Keating <geoffk@apple.com> + + * gcc.dg/pch/cpp-1.h: New. + * gcc.dg/pch/cpp-1.c: New. + * gcc.dg/pch/cpp-2.h: New. + * gcc.dg/pch/cpp-2.c: New. + + 2002-11-19 Geoffrey Keating <geoffk@apple.com> + + * gcc.dg/pch/except-1.h: New. + * gcc.dg/pch/except-1.c: New. + + 2002-11-13 Geoffrey Keating <geoffk@apple.com> + + * gcc.dg/pch/pch.exp: Ensure that <test>.hp doesn't exist before + running test. + * gcc.dg/pch: Include *.hp not *.h. + * gcc.dg/pch/system-1.h: New. + * gcc.dg/pch/system-1.c: New. + + 2002-11-11 Geoffrey Keating <geoffk@apple.com> + + * gcc.dg/pch/pch.exp: Compare .s files with/without PCH, + rather than trying to build and run a program using PCH. + * gcc.dg/pch: Remove dg-do commands from test files. + + 2002-11-08 Geoffrey Keating <geoffk@apple.com> + + * gcc.dg/pch/macro-3.c: New. + * gcc.dg/pch/macro-3.h: New. + + 2002-11-04 Geoffrey Keating <geoffk@apple.com> + + * gcc.dg/pch/common-1.c: New. + * gcc.dg/pch/common-1.h: New. + * gcc.dg/pch/decl-1.c: New. + * gcc.dg/pch/decl-1.h: New. + * gcc.dg/pch/decl-2.c: New. + * gcc.dg/pch/decl-2.h: New. + * gcc.dg/pch/decl-3.c: New. + * gcc.dg/pch/decl-3.h: New. + * gcc.dg/pch/decl-4.c: New. + * gcc.dg/pch/decl-4.h: New. + * gcc.dg/pch/decl-5.c: New. + * gcc.dg/pch/decl-5.h: New. + * gcc.dg/pch/global-1.c: New. + * gcc.dg/pch/global-1.h: New. + * gcc.dg/pch/inline-1.c: New. + * gcc.dg/pch/inline-1.h: New. + * gcc.dg/pch/inline-2.c: New. + * gcc.dg/pch/inline-2.h: New. + * gcc.dg/pch/static-1.c: New. + * gcc.dg/pch/static-1.h: New. + * gcc.dg/pch/static-2.c: New. + * gcc.dg/pch/static-2.h: New. + + 2002-09-01 Geoffrey Keating <geoffk@redhat.com> + + * g++.dg/pch/pch.exp: Better handle failing testcases. + * gcc.dg/pch/pch.exp: Likewise. + * gcc.dg/pch/macro-1.c: New. + * gcc.dg/pch/macro-1.h: New. + * gcc.dg/pch/macro-2.c: New. + * gcc.dg/pch/macro-2.h: New. + + 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". + 2003-01-09 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> * g++.dg/template/friend14.C: New test. diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp index ea96197332f..d9839608733 100644 --- a/gcc/testsuite/g++.dg/dg.exp +++ b/gcc/testsuite/g++.dg/dg.exp @@ -35,6 +35,7 @@ set tests [prune $tests $srcdir/$subdir/bprob/*] set tests [prune $tests $srcdir/$subdir/compat/*] 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/*] diff --git a/gcc/testsuite/g++.dg/pch/empty.C b/gcc/testsuite/g++.dg/pch/empty.C new file mode 100644 index 00000000000..7aef099f3ef --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/empty.C @@ -0,0 +1,5 @@ +#include "empty.Hp" +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/pch/empty.H b/gcc/testsuite/g++.dg/pch/empty.H new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/empty.H diff --git a/gcc/testsuite/g++.dg/pch/pch.exp b/gcc/testsuite/g++.dg/pch/pch.exp new file mode 100644 index 00000000000..8507e355f53 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/pch.exp @@ -0,0 +1,100 @@ +# 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 + +set old_dg_do_what_default "${dg-do-what-default}" + +# Main loop. +foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.C]] { + global runtests 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]]" + + catch { file delete "$bname.Hp.pch" } + catch { file delete "$bname.H.pch" } + catch { file delete "$bname.s" } + catch { file delete "$bname.s-pch" } + catch { file delete "$bname.Hp" } + + # We don't try to use the loop-optimizing options, since they are highly + # unlikely to make any difference to PCH. + foreach flags { "-g" "-O2 -g" "-O2" } { + verbose "Testing $nshort, $flags" 1 + + # For the header files, the default is to precompile. + set dg-do-what-default precompile + dg-test -keep-output "[file rootname $test].H" $flags "" + + # For the rest, the default is to compile to .s. + set dg-do-what-default compile + + if { [ file exists "$bname.H.pch" ] } { + # To ensure that the PCH is used, not the original header, + # the actual PCH file is renamed to "<foo>.Hp.pch". + file rename "$bname.H.pch" "$bname.Hp.pch" + if { [ is_remote host ] } { + remote_download host "$bname.Hp.pch" + } + + dg-test -keep-output $test $flags "-I." + file delete "$bname.Hp.pch" + if { [ file exists "$bname.s" ] } { + file rename "$bname.s" "$bname.s-pch" + if { [ is_remote host ] } { + remote_upload host "[file rootname $test].H" "$bname.Hp" + } else { + file copy "[file rootname $test].H" "$bname.Hp" + } + dg-test -keep-output $test $flags "-I." + remote_file host delete "$bname.Hp" + set tmp [ diff "$bname.s" "$bname.s-pch" ] + if { $tmp == 0 } { + untested "$nshort $flags assembly comparison" + } elseif { $tmp == 1 } { + pass "$nshort $flags assembly comparison" + } else { + fail "$nshort $flags assembly comparison" + } + file delete "$bname.s" + file delete "$bname.s-pch" + } else { + untested "$nshort $flags assembly comparison" + } + + } else { + untested $nshort + untested "$nshort $flags assembly comparison" + } + } +} + +set dg-do-what-default "$old_dg_do_what_default" + +# All done. +dg-finish diff --git a/gcc/testsuite/g++.dg/pch/system-1.C b/gcc/testsuite/g++.dg/pch/system-1.C new file mode 100644 index 00000000000..a0444bc5941 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/system-1.C @@ -0,0 +1,7 @@ +#include "system-1.Hp" + +int main() +{ + std::cout << "hello world!" << '\n'; + return 0; +} diff --git a/gcc/testsuite/g++.dg/pch/system-1.H b/gcc/testsuite/g++.dg/pch/system-1.H new file mode 100644 index 00000000000..604782e4dc7 --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/system-1.H @@ -0,0 +1 @@ +#include <iostream> diff --git a/gcc/testsuite/gcc.dg/pch/common-1.c b/gcc/testsuite/gcc.dg/pch/common-1.c new file mode 100644 index 00000000000..dcf148a2a72 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/common-1.c @@ -0,0 +1,3 @@ +#include "common-1.hp" +int foo2 = 3; +int zz = 2; diff --git a/gcc/testsuite/gcc.dg/pch/common-1.h b/gcc/testsuite/gcc.dg/pch/common-1.h new file mode 100644 index 00000000000..971e1996a24 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/common-1.h @@ -0,0 +1,3 @@ +static int foo1 = 9; +int foo2; +extern int zz; diff --git a/gcc/testsuite/gcc.dg/pch/cpp-1.c b/gcc/testsuite/gcc.dg/pch/cpp-1.c new file mode 100644 index 00000000000..43256cad545 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/cpp-1.c @@ -0,0 +1,4 @@ +#include "cpp-1.hp" +#if !defined(__GNUC__) +panic! panic! +#endif diff --git a/gcc/testsuite/gcc.dg/pch/cpp-1.h b/gcc/testsuite/gcc.dg/pch/cpp-1.h new file mode 100644 index 00000000000..6e25b021ab5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/cpp-1.h @@ -0,0 +1 @@ +/* Empty. */ diff --git a/gcc/testsuite/gcc.dg/pch/cpp-2.c b/gcc/testsuite/gcc.dg/pch/cpp-2.c new file mode 100644 index 00000000000..b76c22cdb04 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/cpp-2.c @@ -0,0 +1,4 @@ +/* { dg-options "-Wunknown-pragmas -I." } */ +#include "cpp-2.hp" +#pragma GCC poison not_used + diff --git a/gcc/testsuite/gcc.dg/pch/cpp-2.h b/gcc/testsuite/gcc.dg/pch/cpp-2.h new file mode 100644 index 00000000000..6e25b021ab5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/cpp-2.h @@ -0,0 +1 @@ +/* Empty. */ diff --git a/gcc/testsuite/gcc.dg/pch/decl-1.c b/gcc/testsuite/gcc.dg/pch/decl-1.c new file mode 100644 index 00000000000..e4120704d9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-1.c @@ -0,0 +1,2 @@ +#include "decl-1.hp" +int main(void) { return foo; } diff --git a/gcc/testsuite/gcc.dg/pch/decl-1.h b/gcc/testsuite/gcc.dg/pch/decl-1.h new file mode 100644 index 00000000000..399f5d3e7f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-1.h @@ -0,0 +1 @@ +extern int foo; diff --git a/gcc/testsuite/gcc.dg/pch/decl-2.c b/gcc/testsuite/gcc.dg/pch/decl-2.c new file mode 100644 index 00000000000..c374a17e3f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-2.c @@ -0,0 +1,2 @@ +#include "decl-2.hp" +int main(void) { return fun (1, 2); } diff --git a/gcc/testsuite/gcc.dg/pch/decl-2.h b/gcc/testsuite/gcc.dg/pch/decl-2.h new file mode 100644 index 00000000000..99c37269097 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-2.h @@ -0,0 +1,3 @@ +extern int fun (int a, int b); + + diff --git a/gcc/testsuite/gcc.dg/pch/decl-3.c b/gcc/testsuite/gcc.dg/pch/decl-3.c new file mode 100644 index 00000000000..9c95b9ad08e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-3.c @@ -0,0 +1,11 @@ +#include "decl-3.hp" + +foo_p bar (void) +{ + return foop; +} + +struct foo *bar2 (void) +{ + return foop; +} diff --git a/gcc/testsuite/gcc.dg/pch/decl-3.h b/gcc/testsuite/gcc.dg/pch/decl-3.h new file mode 100644 index 00000000000..787d480f208 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-3.h @@ -0,0 +1,3 @@ +struct foo; +typedef struct foo *foo_p; +extern foo_p foop; diff --git a/gcc/testsuite/gcc.dg/pch/decl-4.c b/gcc/testsuite/gcc.dg/pch/decl-4.c new file mode 100644 index 00000000000..3efe3829ffc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-4.c @@ -0,0 +1,9 @@ +#include "decl-4.hp" + +int bar (foo_p f) +{ + if (f->a + foop->a) + return f->c->b + foop->b; + else + return foop->c->b + f->a; +} diff --git a/gcc/testsuite/gcc.dg/pch/decl-4.h b/gcc/testsuite/gcc.dg/pch/decl-4.h new file mode 100644 index 00000000000..3fb220032e0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-4.h @@ -0,0 +1,7 @@ +typedef struct foo { + int a; + char b; + struct foo *c; +} foo_s; +typedef struct foo *foo_p; +extern foo_p foop; diff --git a/gcc/testsuite/gcc.dg/pch/decl-5.c b/gcc/testsuite/gcc.dg/pch/decl-5.c new file mode 100644 index 00000000000..f94b33a1363 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-5.c @@ -0,0 +1,2 @@ +#include "decl-5.hp" +static int (*t)(void) = foo; diff --git a/gcc/testsuite/gcc.dg/pch/decl-5.h b/gcc/testsuite/gcc.dg/pch/decl-5.h new file mode 100644 index 00000000000..914983c4963 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/decl-5.h @@ -0,0 +1 @@ +extern int foo(void); diff --git a/gcc/testsuite/gcc.dg/pch/empty.c b/gcc/testsuite/gcc.dg/pch/empty.c new file mode 100644 index 00000000000..330876cc7c7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/empty.c @@ -0,0 +1,8 @@ +/* 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; +} diff --git a/gcc/testsuite/gcc.dg/pch/empty.h b/gcc/testsuite/gcc.dg/pch/empty.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/empty.h diff --git a/gcc/testsuite/gcc.dg/pch/except-1.c b/gcc/testsuite/gcc.dg/pch/except-1.c new file mode 100644 index 00000000000..0332609de2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/except-1.c @@ -0,0 +1,7 @@ +/* { dg-options "-fexceptions -I." } */ +#include "except-1.hp" + +int main(void) +{ + return foo(1); +} diff --git a/gcc/testsuite/gcc.dg/pch/except-1.h b/gcc/testsuite/gcc.dg/pch/except-1.h new file mode 100644 index 00000000000..33a893d1533 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/except-1.h @@ -0,0 +1,6 @@ +/* { dg-options "-fexceptions" } */ +extern inline int +foo(int a) +{ + return a + 1; +} diff --git a/gcc/testsuite/gcc.dg/pch/global-1.c b/gcc/testsuite/gcc.dg/pch/global-1.c new file mode 100644 index 00000000000..4cab062345e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/global-1.c @@ -0,0 +1,2 @@ +#include "global-1.hp" +const int bar = 3; diff --git a/gcc/testsuite/gcc.dg/pch/global-1.h b/gcc/testsuite/gcc.dg/pch/global-1.h new file mode 100644 index 00000000000..26efffcb2bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/global-1.h @@ -0,0 +1 @@ +const int foo = 2; diff --git a/gcc/testsuite/gcc.dg/pch/inline-1.c b/gcc/testsuite/gcc.dg/pch/inline-1.c new file mode 100644 index 00000000000..7fc32d7f766 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/inline-1.c @@ -0,0 +1,10 @@ +#include "inline-1.hp" +int bar(int a, int b) +{ + return foo(a) + b; +} + +int baz(void) +{ + return foo(3); +} diff --git a/gcc/testsuite/gcc.dg/pch/inline-1.h b/gcc/testsuite/gcc.dg/pch/inline-1.h new file mode 100644 index 00000000000..e8f1d6f138f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/inline-1.h @@ -0,0 +1,5 @@ +extern inline int +foo(int a) +{ + return a * 2 + 1; +} diff --git a/gcc/testsuite/gcc.dg/pch/inline-2.c b/gcc/testsuite/gcc.dg/pch/inline-2.c new file mode 100644 index 00000000000..7792c828b92 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/inline-2.c @@ -0,0 +1,12 @@ +#include "inline-2.hp" +extern inline char +bar(int a) +{ + return foo(a)[0]; +} + +extern inline char +baz(void) +{ + return foo(0)[0]; +} diff --git a/gcc/testsuite/gcc.dg/pch/inline-2.h b/gcc/testsuite/gcc.dg/pch/inline-2.h new file mode 100644 index 00000000000..7d90c63deb9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/inline-2.h @@ -0,0 +1,5 @@ +extern inline const char * +foo(int a) +{ + return "abcdefgh"+a; +} diff --git a/gcc/testsuite/gcc.dg/pch/macro-1.c b/gcc/testsuite/gcc.dg/pch/macro-1.c new file mode 100644 index 00000000000..3775004a77b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/macro-1.c @@ -0,0 +1,6 @@ +#include "macro-1.hp" + +int main(void) +{ + return DEFINED_VALUE + 1 - DEFINED_PARAM (3); +} diff --git a/gcc/testsuite/gcc.dg/pch/macro-1.h b/gcc/testsuite/gcc.dg/pch/macro-1.h new file mode 100644 index 00000000000..5d5b3f4ca65 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/macro-1.h @@ -0,0 +1,2 @@ +#define DEFINED_VALUE 3 +#define DEFINED_PARAM(x) (x+1) diff --git a/gcc/testsuite/gcc.dg/pch/macro-2.c b/gcc/testsuite/gcc.dg/pch/macro-2.c new file mode 100644 index 00000000000..d058e2bb869 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/macro-2.c @@ -0,0 +1,8 @@ +#define DEFINED_VALUE_2 3 + +#include "macro-2.hp" + +int main(void) +{ + return DEFINED_VALUE - DEFINED_VALUE_2; +} diff --git a/gcc/testsuite/gcc.dg/pch/macro-2.h b/gcc/testsuite/gcc.dg/pch/macro-2.h new file mode 100644 index 00000000000..6152a84a877 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/macro-2.h @@ -0,0 +1,2 @@ +#define DEFINED_VALUE 3 + diff --git a/gcc/testsuite/gcc.dg/pch/macro-3.c b/gcc/testsuite/gcc.dg/pch/macro-3.c new file mode 100644 index 00000000000..40ee46e4f3a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/macro-3.c @@ -0,0 +1,8 @@ +#define DEFINED_FUNC_2(x) (3 + (x)) + +#include "macro-3.hp" + +int main(void) +{ + return DEFINED_FUNC (1) - DEFINED_FUNC_2 (-1); +} diff --git a/gcc/testsuite/gcc.dg/pch/macro-3.h b/gcc/testsuite/gcc.dg/pch/macro-3.h new file mode 100644 index 00000000000..d394792a342 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/macro-3.h @@ -0,0 +1,2 @@ +#define DEFINED_FUNC(x) 3 - (x) + diff --git a/gcc/testsuite/gcc.dg/pch/pch.exp b/gcc/testsuite/gcc.dg/pch/pch.exp new file mode 100644 index 00000000000..69422ca3ef0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/pch.exp @@ -0,0 +1,100 @@ +# 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 + +set old_dg_do_what_default "${dg-do-what-default}" + +# 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]]" + + catch { file delete "$bname.hp.pch" } + catch { file delete "$bname.h.pch" } + catch { file delete "$bname.s" } + catch { file delete "$bname.s-pch" } + catch { file delete "$bname.hp" } + + # 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 dg-do-what-default precompile + dg-test -keep-output "[file rootname $test].h" $flags "" + + # For the rest, the default is to compile to .s. + set dg-do-what-default compile + + if { [ file exists "$bname.h.pch" ] } { + # To ensure that the PCH is used, not the original header, + # the actual PCH file is renamed to "<foo>.hp.pch". + file rename "$bname.h.pch" "$bname.hp.pch" + if { [ is_remote host ] } { + remote_download host "$bname.hp.pch" + } + + dg-test -keep-output $test $flags "-I." + file delete "$bname.hp.pch" + if { [ file exists "$bname.s" ] } { + file rename "$bname.s" "$bname.s-pch" + if { [ is_remote host ] } { + remote_upload host "[file rootname $test].h" "$bname.hp" + } else { + file copy "[file rootname $test].h" "$bname.hp" + } + dg-test -keep-output $test $flags "-I." + remote_file host delete "$bname.hp" + set tmp [ diff "$bname.s" "$bname.s-pch" ] + if { $tmp == 0 } { + untested "$nshort $flags assembly comparison" + } elseif { $tmp == 1 } { + pass "$nshort $flags assembly comparison" + } else { + fail "$nshort $flags assembly comparison" + } + file delete "$bname.s" + file delete "$bname.s-pch" + } else { + untested "$nshort $flags assembly comparison" + } + + } else { + untested $nshort + untested "$nshort $flags assembly comparison" + } + } +} + +set dg-do-what-default "$old_dg_do_what_default" + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.dg/pch/static-1.c b/gcc/testsuite/gcc.dg/pch/static-1.c new file mode 100644 index 00000000000..c1816e949b4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/static-1.c @@ -0,0 +1,6 @@ +#include "static-1.hp" +static int bar(void) +{ + static int counter; + return counter++; +} diff --git a/gcc/testsuite/gcc.dg/pch/static-1.h b/gcc/testsuite/gcc.dg/pch/static-1.h new file mode 100644 index 00000000000..08cc4395d0e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/static-1.h @@ -0,0 +1,5 @@ +static int foo(void) +{ + static int counter; + return counter++; +} diff --git a/gcc/testsuite/gcc.dg/pch/static-2.c b/gcc/testsuite/gcc.dg/pch/static-2.c new file mode 100644 index 00000000000..afda874e279 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/static-2.c @@ -0,0 +1,6 @@ +#include "static-2.hp" +int bar(void) +{ + static int counter; + return counter++; +} diff --git a/gcc/testsuite/gcc.dg/pch/static-2.h b/gcc/testsuite/gcc.dg/pch/static-2.h new file mode 100644 index 00000000000..08cc4395d0e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/static-2.h @@ -0,0 +1,5 @@ +static int foo(void) +{ + static int counter; + return counter++; +} diff --git a/gcc/testsuite/gcc.dg/pch/system-1.c b/gcc/testsuite/gcc.dg/pch/system-1.c new file mode 100644 index 00000000000..096fe593e06 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/system-1.c @@ -0,0 +1,6 @@ +#include "system-1.hp" +int main(void) +{ + puts ("hello world!"); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/pch/system-1.h b/gcc/testsuite/gcc.dg/pch/system-1.h new file mode 100644 index 00000000000..fbfff34edb0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pch/system-1.h @@ -0,0 +1,2 @@ +#include <stdio.h> +#include <stdlib.h> diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp index 8be839e4dcf..2fad5d1f7f8 100644 --- a/gcc/testsuite/lib/g++-dg.exp +++ b/gcc/testsuite/lib/g++-dg.exp @@ -37,6 +37,10 @@ proc g++-dg-test { prog do_what extra_tool_flags } { 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" diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 403fefc2f11..dd130b9c37e 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -69,6 +69,10 @@ proc gcc-dg-test { prog do_what extra_tool_flags } { 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" |