summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2750.c
blob: bba64b3ef0d1f9f50f444b5da21d235a2abde7ce (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
/*
   bug1-2195.c

   frontend used | in place of ^.
*/

#include <testfwk.h>

typedef struct
  {
  unsigned LATC0                : 1;
  unsigned LATC1                : 1;
  unsigned LATC2                : 1;
  unsigned LATC3                : 1;
  unsigned LATC4                : 1;
  unsigned LATC5                : 1;
  unsigned LATC6                : 1;
  unsigned LATC7                : 1;
  } LATCbits_t;

#if defined(__SDCC_pic14) // pic14: LATCbits may actually exist in the device
#  define LATCbits fake_LATCbits
#endif

volatile LATCbits_t LATCbits;

unsigned short mask;

void set_bits(unsigned char sn)
{
    LATCbits.LATC0 = ((mask >> sn) & 1) ^ ~0x1;
}

volatile unsigned char bit;

void testBug(void)
{
    LATCbits.LATC0 = 1;
    mask = 0x00;
    bit = 0;
    set_bits(bit);
    ASSERT(!LATCbits.LATC0);
}