1/* { dg-do run } */
2/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
3/* { dg-require-effective-target alloca } */
4
5#include "check.h"
6
7#ifndef ALIGNMENT
8#define ALIGNMENT	64
9#endif
10
11typedef int aligned __attribute__((aligned(ALIGNMENT)));
12extern int strncmp (const char *, const char *, size_t);
13
14int global;
15
16void
17copy (char *p, int size)
18{
19  __builtin_strncpy (p, "good", size);
20}
21
22void
23foo (int size)
24{
25  aligned j;
26
27   __attribute__ ((__noinline__))
28  void bar (int size)
29    {
30      char *p = __builtin_alloca (size + 1);
31      aligned i;
32
33      copy (p, size);
34      if (strncmp (p, "good", size) != 0)
35	{
36#ifdef DEBUG
37	  p[size] = '\0';
38	  printf ("Failed: %s != good\n", p);
39#endif
40	  abort ();
41	}
42
43      if (check_int (&i,  __alignof__(i)) != i)
44	abort ();
45
46      if (check_int (&j,  __alignof__(j)) != j)
47	abort ();
48
49      j = -20;
50    }
51  bar (size);
52
53  if (j != -20)
54    abort ();
55
56  if (check_int (&j,  __alignof__(j)) != j)
57    abort ();
58}
59
60int
61main()
62{
63  foo (5);
64  return 0;
65}
66