Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / g++.dg / torture / stackalign / eh-vararg-1.C
blobb9ba81b1297f4086dbb19620f37ed977c8424753
1 /* { dg-do run } */
2 /* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } "*" "" } */
4 #include <stdarg.h>
5 #include "check.h"
7 #ifndef ALIGNMENT
8 #define ALIGNMENT       64
9 #endif
11 typedef int aligned __attribute__((aligned(ALIGNMENT)));
13 int global;
15 void
16 bar (char *p, int size)
18   __builtin_strncpy (p, "good", size);
21 class Base {};
23 struct A : virtual public Base
25   A() {}
28 struct B {};
30 void
31 foo (const char *fmt, ...) throw (B,A)
33   va_list arg;
34   char *p;
35   aligned i;
36   int size;
37   double x;
39   va_start (arg, fmt);
40   size = va_arg (arg, int);
41   if (size != 5)
42     abort ();
43   p = (char *) __builtin_alloca (size + 1);
45   x = va_arg (arg, double);
46   if (x != 5.0)
47     abort ();
49   bar (p, size);
50   if (__builtin_strncmp (p, "good", size) != 0)
51     {
52 #ifdef DEBUG
53       p[size] = '\0';
54       printf ("Failed: %s != good\n", p);
55 #endif
56       abort ();
57     }
59   if (check_int (&i,  __alignof__(i)) != i)
60     abort ();
62   throw A();
64   va_end (arg);
67 int
68 main()
70   try { foo ("foo", 5, 5.0); }
71   catch (A& a) { }
72   return 0;