1 /* { dg-require-effective-target indirect_jumps } */
2 
3 extern void abort (void);
4 
5 __attribute ((noinline)) void
broken_longjmp(void * p)6 broken_longjmp (void *p)
7 {
8   void *buf[32];
9   __builtin_memcpy (buf, p, 5 * sizeof (void*));
10   __builtin_memset (p, 0, 5 * sizeof (void*));
11   /* Corrupts stack pointer...  */
12   __builtin_longjmp (buf, 1);
13 }
14 
15 volatile int x = 0;
16 char *volatile p;
17 char *volatile q;
18 
19 int
main()20 main ()
21 {
22   void *buf[5];
23   p = __builtin_alloca (x);
24   q = __builtin_alloca (x);
25   if (!__builtin_setjmp (buf))
26     broken_longjmp (buf);
27 
28   /* Compute expected next alloca offset - some targets don't align properly
29      and allocate too much.  */
30   p = q + (q - p);
31 
32   /* Fails if stack pointer corrupted.  */
33   if (p != __builtin_alloca (x))
34     abort ();
35 
36   return 0;
37 }
38