Debian Codegraph @

gcc/testsuite/gcc.dg/torture/stackalign/nested-3.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 extern int strncmp (const char *, const char *, size_t);
12
13 int global;
14
15 void
16 copy (char *p, int size)
17 {
18 __builtin_strncpy (p, "good", size);
19 }
20
21 void
22 foo (int size)
23 {
24 aligned j;
25
26 __attribute__ ((__noinline__))
27 void bar (int size)
28 {
29 char *p = __builtin_alloca (size + 1);
30 aligned i;
31
32 copy (p, size);
33 if (strncmp (p, "good", size) != 0)
34 {
35 #ifdef DEBUG
36 p[size] = '\0';
37 printf ("Failed: %s != good\n", p);
38 #endif
39 abort ();
40 }
41
42 if (check_int (&i, __alignof__(i)) != i)
43 abort ();
44
45 if (check_int (&j, __alignof__(j)) != j)
46 abort ();
47
48 j = -20;
49 }
50 bar (size);
51
52 if (j != -20)
53 abort ();
54
55 if (check_int (&j, __alignof__(j)) != j)
56 abort ();
57 }
58
59 int
60 main()
61 {
62 foo (5);
63 return 0;
64 }