struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / shifts3.c.in
bloba595098bb51a409fed0b097bb107bbd6ec76da38
1 /** Tests covering the shift operators when some bits of the
2 result are known to be the same (since this allows some
3 optimization, see RFE #935, that we want to test here).
5 type: char, int, long
7 */
8 #include <testfwk.h>
10 const int C0[] = {0,1,2};
11 int S0[] = {5,0,1};
13 int r0(void)
16 static signed {type} cy,sy;
17 static signed char x0,x1;
18 static signed char xx0,xx1;
20 int y = 0;
23 while(y<3)
26 cy = C0[y];
27 sy = S0[y];
29 x0 = cy/64;
30 x1 = sy/32;
32 xx0 = (cy<<2)>>8;
33 xx1 = (sy<<3)>>8;
34 y++;
39 return x0+x1;
42 #if !defined(__SDCC_pdk14) // Lack of memory
43 const int C1[] = {0,1,80};
44 int S1[] = {5,0,40};
46 int r1(void)
49 static signed {type} cy,sy;
50 static signed char x0,x1;
51 static signed char xx0,xx1;
53 int y = 0;
56 while(y<3)
59 cy = C1[y];
60 sy = S1[y];
62 x0 = cy/64;
63 x1 = sy/32;
65 xx0 = (cy<<2)>>8;
66 xx1 = (sy<<3)>>8;
67 y++;
72 return x0+x1;
75 #if !defined(__SDCC_pdk15) // Lack of memory
76 const int C2[] = {0,1,-2};
77 int S2[] = {5,0,-1};
79 int r2(void)
82 static signed {type} cy,sy;
83 static signed char x0,x1;
84 static signed char xx0,xx1;
86 int y = 0;
89 while(y<3)
92 cy = C2[y];
93 sy = S2[y];
95 x0 = cy/64;
96 x1 = sy/32;
98 xx0 = (cy<<2)>>8;
99 xx1 = (sy<<3)>>8;
100 y++;
105 return x0+x1;
108 const int C3[] = {0,1,-80};
109 int S3[] = {5,0,-40};
111 int r3(void)
114 static signed {type} cy,sy;
115 static signed char x0,x1;
116 static signed char xx0,xx1;
118 int y = 0;
121 while(y<3)
124 cy = C3[y];
125 sy = S3[y];
127 x0 = cy/64;
128 x1 = sy/32;
130 xx0 = (cy<<2)>>8;
131 xx1 = (sy<<3)>>8;
132 y++;
137 return x0+x1;
139 #endif
140 #endif
142 void testShift(void)
144 ASSERT (r0() == 0);
145 #if !defined(__SDCC_pdk14)
146 ASSERT (r1() == 2);
147 #if !defined(__SDCC_pdk15)
148 ASSERT (r2() == 0);
149 ASSERT (r3() == -2);
150 #endif
151 #endif