Debian Codegraph @

gcc/testsuite/gcc.dg/torture/stackalign/alloca-1.c

raw
1 /* { dg-do run } */
2 /* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } } */
3
4 #include "check.h"
5
6 #ifndef ALIGNMENT
7 #define ALIGNMENT 64
8 #endif
9
10 typedef int aligned __attribute__((aligned(ALIGNMENT)));
11
12 int global;
13
14 void
15 bar (char *p, int size)
16 {
17 __builtin_strncpy (p, "good", size);
18 }
19
20 void
21 foo (int size)
22 {
23 char *p = __builtin_alloca (size + 1);
24 aligned i;
25
26 bar (p, size);
27 if (__builtin_strncmp (p, "good", size) != 0)
28 {
29 #ifdef DEBUG
30 p[size] = '\0';
31 printf ("Failed: %s != good\n", p);
32 #endif
33 abort ();
34 }
35
36 if (check_int (&i, __alignof__(i)) != i)
37 abort ();
38 }
39
40 int
41 main()
42 {
43 foo (5);
44 return 0;
45 }