1 #include "struct-layout-1.h" 2 3 #define F(n, x, v, w) \ 4 if (info.flds[i] != &s##n.x) \ 5 FAIL (n, 50); \ 6 if (info.sizes[i] != sizeof (s##n.x)) \ 7 FAIL (n, 51); \ 8 if (info.aligns[i] != __alignof__ (s##n.x)) \ 9 FAIL (n, 52); \ 10 if (s##n.x != (__typeof__ (s##n.x)) v) \ 11 FAIL (n, 53); \ 12 if (a##n[2].x != (__typeof__ (s##n.x)) w) \ 13 FAIL (n, 54); \ 14 if (arg0.x != s##n.x) \ 15 FAIL (n, 55); \ 16 if (arg2.x != a##n[2].x) \ 17 FAIL (n, 56); \ 18 ret.x = s##n.x; \ 19 ++i; 20 #define N(n, x) \ 21 if (info.flds[i] != &s##n.x) \ 22 FAIL (n, 50); \ 23 if (info.sizes[i] != sizeof (s##n.x)) \ 24 FAIL (n, 51); \ 25 if (info.aligns[i] != __alignof__ (s##n.x)) \ 26 FAIL (n, 52); \ 27 ++i; 28 #define B(n, x, v, w) \ 29 b1.x = v; b2.x = w; \ 30 if (s##n.x != b1.x) \ 31 FAIL (n, 53); \ 32 if (a##n[2].x != b2.x) \ 33 FAIL (n, 54); \ 34 if (arg0.x != s##n.x) \ 35 FAIL (n, 55); \ 36 if (arg2.x != a##n[2].x) \ 37 FAIL (n, 56); \ 38 ret.x = s##n.x; \ 39 ++j; 40 #ifdef CXX14_VS_CXX17 41 struct empty_base {}; 42 #define EMPTY_BASE : public empty_base 43 #else 44 #define EMPTY_BASE 45 #endif 46 #define TX(n, type, attrs, fields, ops) \ 47 type S##n EMPTY_BASE { fields } attrs; \ 48 extern type S##n s##n; \ 49 type S##n a##n[5]; \ 50 type S##n \ 51 check##n (type S##n arg0, type S##n *arg1, type S##n arg2) \ 52 { \ 53 type S##n ret; \ 54 type S##n b1, b2; \ 55 int i, j; \ 56 \ 57 memset (&ret, 0, sizeof (ret)); \ 58 memset (&b1, 0, sizeof (b1)); \ 59 memset (&b2, 0, sizeof (b2)); \ 60 if (info.sp != &s##n) \ 61 FAIL (n, 10); \ 62 if (info.a0p != &a##n[0]) \ 63 FAIL (n, 11); \ 64 if (info.a3p != &a##n[3]) \ 65 FAIL (n, 12); \ 66 if (info.sz != sizeof (s##n)) \ 67 FAIL (n, 13); \ 68 if (info.als != __alignof__ (s##n)) \ 69 FAIL (n, 14); \ 70 if (info.ala0 != __alignof__ (a##n[0])) \ 71 FAIL (n, 15); \ 72 if (info.ala3 != __alignof__ (a##n[3])) \ 73 FAIL (n, 16); \ 74 if (arg1 != &a##n[1]) \ 75 FAIL (n, 17); \ 76 i = 0; j = 0; \ 77 ops \ 78 if (i != info.nfields || j != info.nbitfields) \ 79 FAIL (n, 18); \ 80 \ 81 return ret; \ 82 } 83