1 /* { dg-do run } */
2
3 #include <stdarg.h>
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
bar(char * p,int size)15 bar (char *p, int size)
16 {
17 __builtin_strncpy (p, "good", size);
18 }
19
20 class Base {};
21
22 struct A : virtual public Base
23 {
AA24 A() {}
25 };
26
27 struct B {};
28
29 void
test(va_list arg)30 test (va_list arg) throw (B,A)
31 {
32 char *p;
33 aligned i;
34 int size;
35 double x;
36
37 size = va_arg (arg, int);
38 if (size != 5)
39 abort ();
40
41 p = (char *) __builtin_alloca (size + 1);
42
43 x = va_arg (arg, double);
44 if (x != 5.0)
45 abort ();
46
47 bar (p, size);
48 if (__builtin_strncmp (p, "good", size) != 0)
49 {
50 #ifdef DEBUG
51 p[size] = '\0';
52 printf ("Failed: %s != good\n", p);
53 #endif
54 abort ();
55 }
56
57 if (check_int (&i, __alignof__(i)) != i)
58 abort ();
59
60 throw A();
61 }
62
63 void
foo(const char * fmt,...)64 foo (const char *fmt, ...)
65 {
66 va_list arg;
67 va_start (arg, fmt);
68 test (arg);
69 va_end (arg);
70 }
71 int
main()72 main()
73 {
74 try { foo ("foo", 5, 5.0); }
75 catch (A& a) { }
76 return 0;
77 }
78