summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-10 02:22:34 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-10 02:22:34 +0000
commit573aba856d39e5b11d72261a6ccb6004dcb923cd (patch)
treea3ff2e89f1924fd7ea1d99358736bc8491352747 /gcc/testsuite/gcc.dg
parent4e844289dc2d6aca17add7956465217079eccdb6 (diff)
downloadgcc-573aba856d39e5b11d72261a6ccb6004dcb923cd.tar.gz
Merge from pch-branch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61136 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/pch/common-1.c3
-rw-r--r--gcc/testsuite/gcc.dg/pch/common-1.h3
-rw-r--r--gcc/testsuite/gcc.dg/pch/cpp-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/pch/cpp-1.h1
-rw-r--r--gcc/testsuite/gcc.dg/pch/cpp-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/pch/cpp-2.h1
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-1.h1
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-2.h3
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-3.c11
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-3.h3
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-4.c9
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-4.h7
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/pch/decl-5.h1
-rw-r--r--gcc/testsuite/gcc.dg/pch/empty.c8
-rw-r--r--gcc/testsuite/gcc.dg/pch/empty.h0
-rw-r--r--gcc/testsuite/gcc.dg/pch/except-1.c7
-rw-r--r--gcc/testsuite/gcc.dg/pch/except-1.h6
-rw-r--r--gcc/testsuite/gcc.dg/pch/global-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/pch/global-1.h1
-rw-r--r--gcc/testsuite/gcc.dg/pch/inline-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/pch/inline-1.h5
-rw-r--r--gcc/testsuite/gcc.dg/pch/inline-2.c12
-rw-r--r--gcc/testsuite/gcc.dg/pch/inline-2.h5
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-1.h2
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-2.h2
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-3.c8
-rw-r--r--gcc/testsuite/gcc.dg/pch/macro-3.h2
-rw-r--r--gcc/testsuite/gcc.dg/pch/pch.exp100
-rw-r--r--gcc/testsuite/gcc.dg/pch/static-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/pch/static-1.h5
-rw-r--r--gcc/testsuite/gcc.dg/pch/static-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/pch/static-2.h5
-rw-r--r--gcc/testsuite/gcc.dg/pch/system-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/pch/system-1.h2
39 files changed, 271 insertions, 0 deletions
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>