OSDN Git Service

cp:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / compat / struct-layout-1_x1.h
1 #include "struct-layout-1.h"
2
3 struct Info info;
4 int fails;
5 int intarray[256];
6 int fn0 (void) { return 0; }
7 int fn1 (void) { return 1; }
8 int fn2 (void) { return 2; }
9 int fn3 (void) { return 3; }
10 int fn4 (void) { return 4; }
11 int fn5 (void) { return 5; }
12 int fn6 (void) { return 6; }
13 int fn7 (void) { return 7; }
14 int fn8 (void) { return 8; }
15 int fn9 (void) { return 9; }
16
17 /* This macro is intended for fields where their
18    addresses/sizes/alignments and value passing should be checked.  */
19 #define F(n, x, v, w)                                           \
20   info.flds[i] = &s##n.x;                                       \
21   info.sizes[i] = sizeof (s##n.x);                              \
22   info.aligns[i] = __alignof__ (s##n.x);                        \
23   s##n.x = v;                                                   \
24   a##n[2].x = w;                                                \
25   ++i;
26 /* This macro is for fields where just their addresses/sizes/alignments
27    should be checked.  */
28 #define N(n, x)                                                 \
29   info.flds[i] = &s##n.x;                                       \
30   info.sizes[i] = sizeof (s##n.x);                              \
31   info.aligns[i] = __alignof__ (s##n.x);                        \
32   ++i;
33 /* This macro is for fields where just value passing should be checked.  */
34 #define B(n, x, v, w)                                           \
35   s##n.x = v;                                                   \
36   a##n[2].x = w;                                                \
37   ++j;
38 #define TX(n, type, attrs, fields, ops)                         \
39 type S##n { fields } attrs;                                     \
40 type S##n s##n;                                                 \
41 extern type S##n a##n[5];                                       \
42 extern type S##n check##n (type S##n, type S##n *,              \
43                              type S##n);                        \
44 extern void check##n##va (int i, ...);                          \
45 extern void checkx##n (type S##n);                              \
46 void test##n (void)                                             \
47 {                                                               \
48   int i, j;                                                     \
49   memset (&s##n, '\0', sizeof (s##n));                          \
50   memset (a##n, '\0', sizeof (a##n));                           \
51   memset (&info, '\0', sizeof (info));                          \
52   info.sp = &s##n;                                              \
53   info.a0p = &a##n[0];                                          \
54   info.a3p = &a##n[3];                                          \
55   info.sz = sizeof (s##n);                                      \
56   info.als = __alignof__ (s##n);                                \
57   info.ala0 = __alignof__ (a##n[0]);                            \
58   info.ala3 = __alignof__ (a##n[3]);                            \
59   if (((long) &a##n[3]) & (info.als - 1))                       \
60     FAIL (n, 1);                                                \
61   i = 0; j = 0;                                                 \
62   ops                                                           \
63   info.nfields = i;                                             \
64   info.nbitfields = j;                                          \
65   checkx##n (check##n (s##n, &a##n[1], a##n[2]));               \
66   check##n##va (1, 1.0, s##n, 2LL, a##n[2], a##n[2]);           \
67   check##n##va (2, s##n, s##n, 2.0L, a##n[2], s##n);            \
68 }