summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/compat/struct-layout-1_x1.h
blob: 0c7696fa7dbe65f4a55fe37b82b8839d9a4fa906 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "struct-layout-1.h"

struct Info info;
int fails;
int intarray[256];
int fn0 (void) { return 0; }
int fn1 (void) { return 1; }
int fn2 (void) { return 2; }
int fn3 (void) { return 3; }
int fn4 (void) { return 4; }
int fn5 (void) { return 5; }
int fn6 (void) { return 6; }
int fn7 (void) { return 7; }
int fn8 (void) { return 8; }
int fn9 (void) { return 9; }

/* This macro is intended for fields where their
   addresses/sizes/alignments and value passing should be checked.  */
#define F(n, x, v, w) 						\
  info.flds[i] = &s##n.x;					\
  info.sizes[i] = sizeof (s##n.x);				\
  info.aligns[i] = __alignof__ (s##n.x);			\
  s##n.x = v;							\
  a##n[2].x = w;						\
  ++i;
/* This macro is for fields where just their addresses/sizes/alignments
   should be checked.  */
#define N(n, x) 						\
  info.flds[i] = &s##n.x;					\
  info.sizes[i] = sizeof (s##n.x);				\
  info.aligns[i] = __alignof__ (s##n.x);			\
  ++i;
/* This macro is for fields where just value passing should be checked.  */
#define B(n, x, v, w)						\
  s##n.x = v;							\
  a##n[2].x = w;						\
  ++j;
#define TX(n, type, attrs, fields, ops) 			\
type S##n { fields } attrs;					\
type S##n s##n;							\
extern type S##n a##n[5];					\
extern type S##n check##n (type S##n, type S##n *,		\
			     type S##n);			\
extern void check##n##va (int i, ...);				\
extern void checkx##n (type S##n);				\
void test##n (void)						\
{								\
  int i, j;							\
  memset (&s##n, '\0', sizeof (s##n));				\
  memset (a##n, '\0', sizeof (a##n));				\
  memset (&info, '\0', sizeof (info));				\
  info.sp = &s##n;						\
  info.a0p = &a##n[0];						\
  info.a3p = &a##n[3];						\
  info.sz = sizeof (s##n);					\
  info.als = __alignof__ (s##n);				\
  info.ala0 = __alignof__ (a##n[0]);				\
  info.ala3 = __alignof__ (a##n[3]);				\
  if (((long) &a##n[3]) & (info.als - 1))			\
    FAIL (n, 1);						\
  i = 0; j = 0;							\
  ops								\
  info.nfields = i;						\
  info.nbitfields = j;						\
  checkx##n (check##n (s##n, &a##n[1], a##n[2]));		\
  check##n##va (1, 1.0, s##n, 2LL, a##n[2], a##n[2]);		\
  check##n##va (2, s##n, s##n, 2.0L, a##n[2], s##n);		\
}