struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2452.c
blob4d8679355bf3cc04b8e6f72357d7ce703e6fc913
1 /*
2 bug-2452.c
3 */
5 #include <stdbool.h>
6 #include <testfwk.h>
8 typedef struct
10 unsigned char byte[5];
11 } value_t;
13 static void
14 output_digit (unsigned char n)
16 ASSERT(n == 9);
19 static void
20 calculate_digit (value_t *value)
22 value->byte[4] = 9;
25 int
26 xprint_format (const char *format)
28 value_t value;
29 bool lsd;
30 int i;
32 unsigned char length;
34 while( *format++ )
36 unsigned char store[6];
37 unsigned char *pstore = &store[5];
39 format++;
42 lsd = 1;
43 i = 1;
44 do {
45 value.byte[4] = 0;
47 calculate_digit(&value);
49 if (!lsd)
51 *pstore = (value.byte[4] << 4) | (value.byte[4] >> 4) | *pstore;
52 pstore--;
54 else
56 *pstore = value.byte[4];
59 lsd = !lsd;
60 } while( i-- );
62 length = 2;
64 ASSERT(lsd);
66 while( length-- )
68 lsd = !lsd;
69 if (!lsd)
71 pstore++;
72 value.byte[4] = *pstore >> 4;
74 else
76 value.byte[4] = *pstore & 0x0F;
79 output_digit( value.byte[4]);
83 return 0;
86 void
87 test_xprintf (void)
89 xprint_format ("%d");