aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2000-11-16 19:45:23 +0000
committerNick Clifton <nickc@gcc.gnu.org>2000-11-16 19:45:23 +0000
commite24fa9dac1d7f5d1a628f04a1952a38eff8d2d23 (patch)
tree78cbfb40f6c53135f9ad88c84f53206b9b844f50 /gcc/testsuite
parent68dfd979ac149deff93a104e4bb4d7a37ccd2123 (diff)
downloadgcc-e24fa9dac1d7f5d1a628f04a1952a38eff8d2d23.zip
gcc-e24fa9dac1d7f5d1a628f04a1952a38eff8d2d23.tar.gz
gcc-e24fa9dac1d7f5d1a628f04a1952a38eff8d2d23.tar.bz2
Add a couple of new test cases for nested function support.
From-SVN: r37504
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/nestfunc-2.c49
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/nestfunc-3.c60
3 files changed, 114 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 716c5fd..d0c3dbf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2000-11-16 Nick Clifton <nickc@redhat.com>
+
+ * gcc.c-torture/execute/nestfunc-2.c: New test.
+ * gcc.c-torture/execute/nestfunc-3.c: New test.
+
2000-11-11 Bernd Schmidt <bernds@redhat.co.uk>
* gcc.c-torture/compile/20001116-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/nestfunc-2.c b/gcc/testsuite/gcc.c-torture/execute/nestfunc-2.c
new file mode 100644
index 0000000..0308755
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/nestfunc-2.c
@@ -0,0 +1,49 @@
+extern int foo (int, int, int (*) (int, int, int, int, int, int, int));
+
+int z;
+
+int
+main (void)
+{
+#ifndef NO_TRAMPOLINES
+ int sum = 0;
+ int i;
+
+ int nested (int a, int b, int c, int d, int e, int f, int g)
+ {
+ z = c + d + e + f + g;
+
+ if (a > 2 * b)
+ return a - b;
+ else
+ return b - a;
+ }
+
+ for (i = 0; i < 10; ++i)
+ {
+ int j;
+
+ for (j = 0; j < 10; ++j)
+ {
+ int k;
+
+ for (k = 0; k < 10; ++k)
+ sum += foo (i, j > k ? j - k : k - j, nested);
+ }
+ }
+
+ if (sum != 2300)
+ abort ();
+
+ if (z != 0x1b)
+ abort ();
+#endif
+
+ exit (0);
+}
+
+int
+foo (int a, int b, int (* fp) (int, int, int, int, int, int, int))
+{
+ return fp (a, b, a, b, a, b, a);
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/nestfunc-3.c b/gcc/testsuite/gcc.c-torture/execute/nestfunc-3.c
new file mode 100644
index 0000000..653a5da
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/nestfunc-3.c
@@ -0,0 +1,60 @@
+
+extern long foo (long, long, long (*) (long, long));
+extern long use (long (*) (long, long), long, long);
+
+int
+main (void)
+{
+#ifndef NO_TRAMPOLINES
+ long sum = 0;
+ long i;
+
+ long nested_0 (long a, long b)
+ {
+ if (a > 2 * b)
+ return a - b;
+ else
+ return b - a;
+ }
+
+ long nested_1 (long a, long b)
+ {
+ return use (nested_0, b, a) + sum;
+ }
+
+ long nested_2 (long a, long b)
+ {
+ return nested_1 (b, a);
+ }
+
+ for (i = 0; i < 10; ++i)
+ {
+ long j;
+
+ for (j = 0; j < 10; ++j)
+ {
+ long k;
+
+ for (k = 0; k < 10; ++k)
+ sum += foo (i, j > k ? j - k : k - j, nested_2);
+ }
+ }
+
+ if (sum != 0xbecfcbf5)
+ abort ();
+#endif
+
+ exit (0);
+}
+
+long
+use (long (* func)(long, long), long a, long b)
+{
+ return func (b, a);
+}
+
+long
+foo (long a, long b, long (* func) (long, long))
+{
+ return func (a, b);
+}