summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2558.c
blob: 7a5f09b7578ba00f45b5ae100d2fe80597ac8a48 (plain) (blame)
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
/* bug-2807.c
   Sign of % operand lost in redundancy elimination.
 */

#include <testfwk.h>

#include <stdint.h>

#if !defined( __SDCC_pdk14) && !defined( __SDCC_pdk15) // Bug #2874
uint16_t x;

static inline uint16_t llvm_srem_u16(int16_t a, int16_t b) {
  uint16_t r = a % b;
  return r;
}

static inline uint16_t returnx(void)
{
  return x;
}

void foo(void)
{
  x=llvm_srem_u16(x,returnx());
}
#endif

void testBug(void)
{
#if !defined( __SDCC_pdk14) && !defined( __SDCC_pdk15) // Bug #2874
  x = (unsigned)(-1);
  foo();
  ASSERT (x == (unsigned)(-23) % (unsigned)(-23));
#endif
}