struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-524195.c
blob8ebb264857afe81dae4174a86f0659ab4fc870bb
1 /* Problem with inverting constants
2 */
3 #include <testfwk.h>
5 enum
7 USEDFLAG = 1
8 };
10 typedef struct _HeapEntry HeapEntry;
11 typedef unsigned int UINT;
13 struct _HeapEntry
15 HeapEntry *pPrev;
16 HeapEntry *pNext;
17 UINT uSize;
20 static UINT _getSize1(HeapEntry *pEnt)
22 return pEnt->uSize & ~USEDFLAG;
25 static UINT _getSize2(HeapEntry *pEnt)
27 return pEnt->uSize & ~1;
30 static UINT _getSize3(HeapEntry *pEnt)
32 return pEnt->uSize & 0xFFFE;
35 static void
36 testMask(void)
38 HeapEntry ent;
39 ent.uSize = 123;
41 ASSERT(_getSize1(&ent) == 122);
42 ASSERT(_getSize2(&ent) == 122);
43 ASSERT(_getSize3(&ent) == 122);
45 ent.uSize = 0x1234;
46 ASSERT(_getSize1(&ent) == 0x1234);
47 ASSERT(_getSize2(&ent) == 0x1234);
48 ASSERT(_getSize3(&ent) == 0x1234);