summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-460000.c
blob: 8183ca7c1aab71eff1198bb1f1f44915c2136f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* bug 460000
   Right shift of negative values is implementation-defined by SDCC to arithmetic right shift.
 */
#include <testfwk.h>

int 
func( int a )
{
  return a;
}

int x = -1024; 

void 
testByteShift(void) 
{ 
  ASSERT(func( x >> 8 ) == -4);
  ASSERT(func( x / 256 ) == -4);
} 

void
testOtherSignedShifts(void)
{
  volatile int left;

  left = -2345;
  ASSERT(left >> 3 == (-2345>>3));
  ASSERT(left >> 8 == (-2345>>8));
  ASSERT(left >> 9 == (-2345>>9));
}

void
testShiftByParam(void)
{
  volatile int left, count;

  left = -2345;

  count = 3;
  ASSERT(left >> count == (-2345>>3));
  count = 8;
  ASSERT(left >> count == (-2345>>8));
  count = 9;
  ASSERT(left >> count == (-2345>>9));
}