Debian Codegraph @

gcc/testsuite/g++.dg/torture/stackalign/eh-inline-2.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
12 int global;
13
14 void
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 {
24 A() {}
25 };
26
27 struct B {};
28
29 static void
30 inline __attribute__((always_inline))
31 foo (int size)
32 #if __cplusplus <= 201402L
33 throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
34 #endif
35 {
36 char *p = (char *) __builtin_alloca (size + 1);
37 aligned i;
38
39 bar (p, size);
40 if (__builtin_strncmp (p, "good", size) != 0)
41 {
42 #ifdef DEBUG
43 p[size] = '\0';
44 printf ("Failed: %s != good\n", p);
45 #endif
46 abort ();
47 }
48
49 if (check_int (&i, __alignof__(i)) != i)
50 abort ();
51
52 throw A();
53 }
54
55 int
56 main()
57 {
58 try { foo (5); }
59 catch (A& a) { }
60 return 0;
61 }