comparison gcc/testsuite/g++.dg/torture/stackalign/eh-vararg-2.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* { dg-options "-Wno-abi" {target arm_eabi} } */
2 /* { dg-do run } */
3 /* { dg-skip-if "Stack alignment is too small" { hppa*-*-hpux* } } */
4
5 #include <stdarg.h>
6 #include "check.h"
7
8 #ifndef ALIGNMENT
9 #define ALIGNMENT 64
10 #endif
11
12 typedef int aligned __attribute__((aligned(ALIGNMENT)));
13
14 int global;
15
16 void
17 bar (char *p, int size)
18 {
19 __builtin_strncpy (p, "good", size);
20 }
21
22 class Base {};
23
24 struct A : virtual public Base
25 {
26 A() {}
27 };
28
29 struct B {};
30
31 void
32 test (va_list arg)
33 #if __cplusplus <= 201402L
34 throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
35 #endif
36 {
37 char *p;
38 aligned i;
39 int size;
40 double x;
41
42 size = va_arg (arg, int);
43 if (size != 5)
44 abort ();
45
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
68 void
69 foo (const char *fmt, ...)
70 {
71 va_list arg;
72 va_start (arg, fmt);
73 test (arg);
74 va_end (arg);
75 }
76 int
77 main()
78 {
79 try { foo ("foo", 5, 5.0); }
80 catch (A& a) { }
81 return 0;
82 }