2 !!DESCRIPTION!! Make sure that the fields of anonymous structs/unions can be reached properly.
3 !!ORIGIN!! cc65 regression tests
4 !!LICENCE!! Public Domain
11 static unsigned char fails = 0;
74 /* We use "variables" in the comparisons, so that we can avoid "constant
75 ** comparison" and "Unreachable code" warnings (the second one currently
76 ** can't be suppressed).
79 static size_t const zero = 0;
80 static size_t const one = 1;
81 static size_t const three = 3;
82 static size_t const five = 5;
83 static size_t const six = 6;
84 static size_t const seven = 7;
85 static size_t const nine = 9;
89 /* Can cc65 see the names of members of anonymous structs/unions? */
105 /* Does cc65 use the correct offsets of
106 ** the members of anonymous structs/unions?
109 if (offsetof(s1_t, i1) != three) {
110 printf("The offset of s1.i1 is %u; it should be 3.\n", offsetof(s1_t, i1));
113 if (offsetof(s2_t, l1) != one) {
114 printf("The offset of s2.l1 is %u; it should be 1.\n", offsetof(s2_t, l1));
117 if (offsetof(u1_t, c1) != six) {
118 printf("The offset of u1.c1 is %u; it should be 6.\n", offsetof(u1_t, c1));
121 if (offsetof(u2_t, i1) != zero) {
122 printf("The offset of u2.i1 is %u; it should be 0.\n", offsetof(u2_t, i1));
126 /* Does cc65 use the correct offset of a member
127 ** that's later than an anonymous struct/union?
130 if (offsetof(s1_t, c2) != nine) {
131 printf("The offset of s1.c2 is %u; it should be 9.\n", offsetof(s1_t, c2));
134 if (offsetof(s2_t, s1) != five) {
135 printf("The offset of s2.s1 is %u; it should be 5.\n", offsetof(s2_t, s1));
138 if (offsetof(u1_t, c2) != zero) {
139 printf("The offset of u1.c2 is %u; it should be 0.\n", offsetof(u1_t, c2));
142 if (offsetof(u2_t, c2) != zero) {
143 printf("The offset of u2.c2 is %u; it should be 0.\n", offsetof(u2_t, c2));
146 if (offsetof(s3_t, s2) != seven) {
147 printf("The offset of s3.s2 is %u; it should be 7.\n", offsetof(s3_t, s2));