struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2621.c.in
blobdd5e545a0aad98471a801310d9a2117e0b455fd6
1 /* Test for bugs in equality comparison that are sensitive to regoster allocation (as #2621 was)
3 type: unsigned long, unsigned long long
5 */
7 #include <testfwk.h>
9 #ifndef __SDCC_ds390
11 void t(unsigned int i)
16 /* Try to get lower 16 bits allocated to register x on stm8 */
17 {type} f( {type} p)
19 register {type} v = p;
21 if(v == 0x0000ffff)
22 t((unsigned int)v);
23 else if(v == 0x00010000)
24 t((unsigned int)v + 1);
25 else if(v == 0xffff0001)
26 t((unsigned int)v + 42);
27 else
28 return(v);
30 return(v);
33 #ifndef __SDCC_pdk14 // Lack of memory
34 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
35 /* Try to get lower 16 bits allocated to register y on stm8*/
36 {type} g({type} p)
38 register {type} v = p;
40 if(v == 0x0000ffff)
41 t((unsigned int)(v >> 16));
42 else if(v == 0x00010000)
43 t((unsigned int)(v >> 16) + 1);
44 else if(v == 0xffff0001)
45 t((unsigned int)(v >> 16) + 42);
46 else
47 return(v);
50 return(v >> 16);
53 /* Try to get lower 8 bits allocated to register a on stm8*/
54 {type} h( {type} p)
56 register {type} v = p;
58 if(v == 0x0000ffff)
59 v |= 0x55;
60 else if(v == 0x00010000)
61 v &= 0x55;
62 else if(v == 0xffff0001)
63 v |= 0xaa;
64 else
65 return(v);
67 return(v);
69 #endif
70 #endif
71 #endif
73 void testBug(void)
75 #ifndef __SDCC_ds390
76 ASSERT(f(0x55aa55aa) == 0x55aa55aa);
77 ASSERT(f(0x0000ffff) == 0x0000ffff);
78 #ifndef __SDCC_pdk14 // Lack of memory
79 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
80 ASSERT(f(0xffff0001) == 0xffff0001);
82 ASSERT(g(0x55aa55aa) == 0x55aa55aa);
83 ASSERT(g(0x0000ffff) == 0x00000000);
84 ASSERT(g(0xffff0001) == 0x0000ffff);
86 ASSERT(h(0x55aa55aa) == 0x55aa55aa);
87 ASSERT(h(0x0000ffff) == 0x0000ffff);
88 ASSERT(h(0xffff0001) == 0xffff00ab);
89 #endif
90 #endif
91 #endif