OSDN Git Service

* gcc.c-torture/execute/nestfunc-4.c: New test.
authorhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Jan 2002 03:56:05 +0000 (03:56 +0000)
committerhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Jan 2002 03:56:05 +0000 (03:56 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48556 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 01e7111..2d35e8c 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-05  Hans-Peter Nilsson  <hp@bitrange.com>
+
+       * gcc.c-torture/execute/nestfunc-4.c: New test.
+
 2002-01-04  Loren J. Rittle  <ljrittle@acm.org>
 
         * g++.old-deja/g++.abi/aggregates.C: Corrected last patch: removed
diff --git a/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c b/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c
new file mode 100644 (file)
index 0000000..e028166
--- /dev/null
@@ -0,0 +1,37 @@
+/* Origin: hp@bitrange.com
+   Test that return values come out right from a 1000-level call chain to
+   functions without parameters that each need at least one "long"
+   preserved.  Exposed problems related to the MMIX port.  */
+
+long level = 0;
+extern long foo (void);
+extern long bar (void);
+
+#ifdef STACK_SIZE
+#define DEPTH ((STACK_SIZE) / 512 + 1)
+#else
+#define DEPTH 500
+#endif
+
+int
+main (void)
+{
+  if (foo () == -42)
+    exit (0);
+
+  abort ();
+}
+
+long
+foo (void)
+{
+  long tmp = ++level;
+  return bar () + tmp;
+}
+
+long
+bar (void)
+{
+  long tmp = level;
+  return tmp > DEPTH - 1 ? -42 - tmp : foo () - tmp;
+}