struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug3565757.c
blob3dc73f419e30ef15666f681df61c7583cdad3007
1 /*
2 bug3565757.c
3 */
5 #include <testfwk.h>
7 #pragma std_c99
8 #pragma disable_warning 85
10 #include <stdint.h>
11 #include <stdbool.h>
12 #include <string.h>
14 typedef uint_least16_t edge_index_t;
16 struct edge_t
18 uint_fast8_t u[2];
19 uint_fast8_t v[2];
20 edge_index_t prev;
21 edge_index_t next;
22 bool in_stix;
25 #ifndef __SDCC_pdk14 // Lack of memory
26 struct edge_t edges[4];
28 void init_edges(void)
32 void get_edge(struct edge_t *const e, const edge_index_t e_i)
36 void set_edge(const edge_index_t e_i, const struct edge_t *const e)
38 memcpy(edges + e_i, e, sizeof(struct edge_t));
41 const uint_fast8_t vertices[4][2] = {{7, 188}, {248, 188}, {248, 9}, {7, 9}};
43 struct edge_t edge_cache;
45 void init_geometry(void)
47 edge_index_t i;
48 init_edges();
50 for(i = 0; i < 4; i++)
52 get_edge(&edge_cache, i);
53 edge_cache.u[0] = vertices[(i + 0) % 4][0];
54 edge_cache.u[1] = vertices[(i + 0) % 4][1];
55 edge_cache.v[0] = vertices[(i + 1) % 4][0];
56 edge_cache.v[1] = vertices[(i + 1) % 4][1];
57 edge_cache.prev = (i + 3) % 4;
58 edge_cache.next = (i + 1) % 4;
59 set_edge(i, &edge_cache);
62 #endif
64 void testBug(void)
66 #ifndef __SDCC_pdk14 // Lack of memory
67 init_geometry();
69 ASSERT(edges[0].prev = 3);
70 ASSERT(edges[3].prev = 2);
71 #endif