(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr85388-6.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 -O2 -fcf-protection" } */
       5  /* { dg-options "-fsplit-stack -O2 -mno-accumulate-outgoing-args -fcf-protection" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
       6  
       7  /* A case that used to fail on 32-bit x86 when optimizing and not
       8     using -maccumulate-args.  The stack adjustment of the alloca got
       9     mixed up with the arguments pushed on the stack to the function
      10     before the call of alloca.  */
      11  
      12  #include <stdlib.h>
      13  
      14  typedef struct { const char* s; int l; } s;
      15  
      16  typedef unsigned long long align16 __attribute__ ((aligned(16)));
      17  
      18  s gobats (const void *, int) __attribute__ ((noinline));
      19  
      20  s
      21  gobats (const void* p __attribute__ ((unused)),
      22  	int l __attribute__ ((unused)))
      23  {
      24    s v;
      25    v.s = 0;
      26    v.l = 0;
      27    return v;
      28  }
      29  
      30  void check_aligned (void *p) __attribute__ ((noinline));
      31  
      32  void
      33  check_aligned (void *p)
      34  {
      35    if (((__SIZE_TYPE__) p & 0xf) != 0)
      36      abort ();
      37  }
      38  
      39  void gap (void *) __attribute__ ((noinline));
      40  
      41  void gap (void *p)
      42  {
      43    align16 a;
      44    check_aligned (&a);
      45  }
      46  
      47  int
      48  main (int argc, char **argv)
      49  {
      50    s *space;
      51    gobats(0, 16);
      52    space = (s *) alloca(sizeof(s) + 1);
      53    *space = (s){0, 16};
      54    gap(space);
      55    return 0;
      56  }