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