1 /* { dg-do run } */
2 /* { dg-require-effective-target split_stack } */
3 /* { dg-options "-fsplit-stack" } */
4 
5 /* This test is like split-3.c, but tests with a smaller stack frame,
6    since that uses a different prologue.  */
7 
8 #include <stdarg.h>
9 #include <stdlib.h>
10 
11 /* Use a noinline function to ensure that the buffer is not removed
12    from the stack.  */
13 static void use_buffer (char *buf) __attribute__ ((noinline));
14 static void
use_buffer(char * buf)15 use_buffer (char *buf)
16 {
17   buf[0] = '\0';
18 }
19 
20 /* When using gold, the call to abort will force a stack split.  */
21 
22 static void
down(int i,...)23 down (int i, ...)
24 {
25   char buf[1];
26   va_list ap;
27 
28   va_start (ap, i);
29   if (va_arg (ap, int) != 1
30       || va_arg (ap, int) != 2
31       || va_arg (ap, int) != 3
32       || va_arg (ap, int) != 4
33       || va_arg (ap, int) != 5
34       || va_arg (ap, int) != 6
35       || va_arg (ap, int) != 7
36       || va_arg (ap, int) != 8
37       || va_arg (ap, int) != 9
38       || va_arg (ap, int) != 10)
39     abort ();
40 
41   if (i > 0)
42     {
43       use_buffer (buf);
44       down (i - 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
45     }
46 }
47 
48 int
main(void)49 main (void)
50 {
51   down (1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
52   return 0;
53 }
54