| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } } */ |
| 3 |
|
| 4 |
#include <stdarg.h> |
| 5 |
#include "check.h" |
| 6 |
|
| 7 |
#ifndef ALIGNMENT |
| 8 |
#define ALIGNMENT 64 |
| 9 |
#endif |
| 10 |
|
| 11 |
typedef int aligned __attribute__((aligned(ALIGNMENT))); |
| 12 |
|
| 13 |
int global; |
| 14 |
|
| 15 |
void |
| 16 |
bar (char *p, int size) |
| 17 |
{ |
| 18 |
__builtin_strncpy (p, "good", size); |
| 19 |
} |
| 20 |
|
| 21 |
class Base {}; |
| 22 |
|
| 23 |
struct A : virtual public Base |
| 24 |
{ |
| 25 |
A() {} |
| 26 |
}; |
| 27 |
|
| 28 |
struct B {}; |
| 29 |
|
| 30 |
void |
| 31 |
foo (const char *fmt, ...) |
| 32 |
#if __cplusplus <= 201402L |
| 33 |
throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } } |
| 34 |
#endif |
| 35 |
{ |
| 36 |
va_list arg; |
| 37 |
char *p; |
| 38 |
aligned i; |
| 39 |
int size; |
| 40 |
double x; |
| 41 |
|
| 42 |
va_start (arg, fmt); |
| 43 |
size = va_arg (arg, int); |
| 44 |
if (size != 5) |
| 45 |
abort (); |
| 46 |
p = (char *) __builtin_alloca (size + 1); |
| 47 |
|
| 48 |
x = va_arg (arg, double); |
| 49 |
if (x != 5.0) |
| 50 |
abort (); |
| 51 |
|
| 52 |
bar (p, size); |
| 53 |
if (__builtin_strncmp (p, "good", size) != 0) |
| 54 |
{ |
| 55 |
#ifdef DEBUG |
| 56 |
p[size] = '\0'; |
| 57 |
printf ("Failed: %s != good\n", p); |
| 58 |
#endif |
| 59 |
abort (); |
| 60 |
} |
| 61 |
|
| 62 |
if (check_int (&i, __alignof__(i)) != i) |
| 63 |
abort (); |
| 64 |
|
| 65 |
throw A(); |
| 66 |
|
| 67 |
va_end (arg); |
| 68 |
} |
| 69 |
|
| 70 |
int |
| 71 |
main() |
| 72 |
{ |
| 73 |
try { foo ("foo", 5, 5.0); } |
| 74 |
catch (A& a) { } |
| 75 |
return 0; |
| 76 |
} |