* Added.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 1 Mar 2002 05:00:06 +0000 (05:00 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 1 Mar 2002 05:00:06 +0000 (05:00 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1957 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/regression/tests/bug-524195.c [new file with mode: 0644]

diff --git a/support/regression/tests/bug-524195.c b/support/regression/tests/bug-524195.c
new file mode 100644 (file)
index 0000000..8ebb264
--- /dev/null
@@ -0,0 +1,49 @@
+/* Problem with inverting constants
+ */
+#include <testfwk.h>
+
+enum 
+  {
+    USEDFLAG = 1
+  };
+
+typedef struct _HeapEntry HeapEntry;
+typedef unsigned int UINT;
+
+struct _HeapEntry
+{
+  HeapEntry *pPrev;
+  HeapEntry *pNext;
+  UINT uSize;
+};
+
+static UINT _getSize1(HeapEntry *pEnt)
+{
+  return pEnt->uSize & ~USEDFLAG;
+}
+
+static UINT _getSize2(HeapEntry *pEnt)
+{
+  return pEnt->uSize & ~1;
+}
+
+static UINT _getSize3(HeapEntry *pEnt)
+{
+  return pEnt->uSize & 0xFFFE;
+}
+
+static void
+testMask(void)
+{
+  HeapEntry ent;
+  ent.uSize = 123;
+
+  ASSERT(_getSize1(&ent) == 122);
+  ASSERT(_getSize2(&ent) == 122);
+  ASSERT(_getSize3(&ent) == 122);
+
+  ent.uSize = 0x1234;
+  ASSERT(_getSize1(&ent) == 0x1234);
+  ASSERT(_getSize2(&ent) == 0x1234);
+  ASSERT(_getSize3(&ent) == 0x1234);
+}