Add a couple of new test cases for nested function support.
authorNick Clifton <nickc@redhat.com>
Thu, 16 Nov 2000 19:45:23 +0000 (19:45 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Thu, 16 Nov 2000 19:45:23 +0000 (19:45 +0000)
From-SVN: r37504

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/nestfunc-2.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/nestfunc-3.c [new file with mode: 0644]

index 716c5fdd24c27344818b92df296c36c4edad621c..d0c3dbf8adb208552bd003c8143e2ef781f0c27e 100644 (file)
@@ -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 (file)
index 0000000..0308755
--- /dev/null
@@ -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 (file)
index 0000000..653a5da
--- /dev/null
@@ -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);
+}