(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
pr59644.c
       1  /* PR target/59644 */
       2  /* { dg-do run { target lp64 } } */
       3  /* { dg-options "-O2 -ffreestanding -mno-sse -mpreferred-stack-boundary=3 -maccumulate-outgoing-args -mno-red-zone" } */
       4  
       5  /* This test uses __builtin_trap () instead of e.g. abort,
       6     because due to -mpreferred-stack-boundary=3 it should not call
       7     any library function from within main ().  */
       8  
       9  #include <stdarg.h>
      10  
      11  __attribute__((noinline, noclone))
      12  int
      13  bar (int x, int y, int z, int w, const char *fmt, va_list ap)
      14  {
      15    if (x != 1 || y != 2 || z != 3 || w != 4)
      16      __builtin_trap ();
      17    if (fmt[0] != 'f' || fmt[1] != 'o' || fmt[2] != 'o' || fmt[3])
      18      __builtin_trap ();
      19    if (va_arg (ap, int) != 5 || va_arg (ap, int) != 6
      20        || va_arg (ap, long long) != 7LL)
      21      __builtin_trap ();
      22    return 9;
      23  }
      24  
      25  __attribute__((noinline, noclone, optimize ("Os")))
      26  int
      27  foo (const char *fmt, ...)
      28  {
      29    va_list ap;
      30    va_start (ap, fmt);
      31    int r = bar (1, 2, 3, 4, fmt, ap);
      32    va_end (ap);
      33    return r;
      34  }
      35  
      36  int
      37  main ()
      38  {
      39    if (foo ("foo", 5, 6, 7LL) != 9)
      40      __builtin_trap ();
      41    return 0;
      42  }