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  #ifdef CXX14_VS_CXX17
      39  struct empty_base {};
      40  #define EMPTY_BASE : public empty_base
      41  #else
      42  #define EMPTY_BASE
      43  #endif
      44  #define TX(n, type, attrs, fields, ops) 			\
      45  type S##n EMPTY_BASE { fields } attrs;				\
      46  type S##n s##n;							\
      47  extern type S##n a##n[5];					\
      48  extern type S##n check##n (type S##n, type S##n *,		\
      49  			     type S##n);			\
      50  extern void check##n##va (int i, ...);				\
      51  extern void checkx##n (type S##n);				\
      52  void test##n (void)						\
      53  {								\
      54    int i, j;							\
      55    memset (&s##n, '\0', sizeof (s##n));				\
      56    memset (a##n, '\0', sizeof (a##n));				\
      57    memset (&info, '\0', sizeof (info));				\
      58    info.sp = &s##n;						\
      59    info.a0p = &a##n[0];						\
      60    info.a3p = &a##n[3];						\
      61    info.sz = sizeof (s##n);					\
      62    info.als = __alignof__ (s##n);				\
      63    info.ala0 = __alignof__ (a##n[0]);				\
      64    info.ala3 = __alignof__ (a##n[3]);				\
      65    if (((long) (__SIZE_TYPE__) &a##n[3]) & (info.als - 1))			\
      66      FAIL (n, 1);						\
      67    i = 0; j = 0;							\
      68    ops								\
      69    info.nfields = i;						\
      70    info.nbitfields = j;						\
      71    checkx##n (check##n (s##n, &a##n[1], a##n[2]));		\
      72    check##n##va (1, 1.0, s##n, 2LL, a##n[2], a##n[2]);		\
      73    check##n##va (2, s##n, s##n, 2.0L, a##n[2], s##n);		\
      74  }