From dc770b393e071b4d87a02b4ed1209aae065298f9 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Fri, 29 Aug 2003 15:21:02 +0000 Subject: [PATCH] fixed for 64 bit hosts git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2861 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- support/regression/tests/literalop.c | 41 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/support/regression/tests/literalop.c b/support/regression/tests/literalop.c index 23b42c4f..e66585dd 100644 --- a/support/regression/tests/literalop.c +++ b/support/regression/tests/literalop.c @@ -1,9 +1,16 @@ /* Test operandOperation() in SDCCicode.c - type: char, short, long + type: char, short, LONG */ #include +/* 64 bit hosts */ +#if defined(__alpha) || defined(__amd64) +# define LONG int +#else +# define LONG long +#endif + typedef signed {type} stype; typedef unsigned {type} utype; @@ -18,22 +25,22 @@ volatile char is8 = 8; signed char sc; signed short ss; -signed long sl; +signed LONG sl; unsigned char uc; unsigned short us; -unsigned long ul; +unsigned LONG ul; volatile signed char vsc; volatile signed short vss; -volatile signed long vsl; +volatile signed LONG vsl; volatile unsigned char vuc; volatile unsigned short vus; -volatile unsigned long vul; +volatile unsigned LONG vul; stype s; volatile stype vs; utype u; volatile utype vu; -unsigned long t1, t2; +unsigned LONG t1, t2; void testOpOp(void) @@ -47,27 +54,27 @@ testOpOp(void) ASSERT((unsigned char ) 0xfffffff8 * (unsigned char ) 0xfffffff7 == 0xef48); ASSERT((unsigned short) 0xfffffff8 * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 0x0048 : 0xffef0048)); - ASSERT((unsigned long ) 0xfffffff8 * (unsigned long ) 0xfffffff7 == 0x0048); + ASSERT((unsigned LONG ) 0xfffffff8 * (unsigned LONG ) 0xfffffff7 == 0x0048); ASSERT((stype ) 0xfffffff8 * (stype ) 0xfffffff7 == 72); ASSERT((signed char ) -1 * (unsigned char ) 0xfffffff7 == (sizeof(int) == 2 ? 0xff09 : 0xffffff09)); ASSERT((signed short) -1 * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 9u : 0xffff0009)); - ASSERT((signed long ) -1 * (unsigned long ) 0xfffffff7 == 9u); + ASSERT((signed LONG ) -1 * (unsigned LONG ) 0xfffffff7 == 9u); ASSERT((signed char ) -2 * (unsigned char ) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffffff8)); ASSERT((signed short) -2 * (unsigned short) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffefff8)); - ASSERT((signed long ) -2 * (unsigned long ) 0x8004 == 0xfffefff8); + ASSERT((signed LONG ) -2 * (unsigned LONG ) 0x8004 == 0xfffefff8); ASSERT(-1 * 0xfff7 == (sizeof(int) == 2 ? 9 : 0xffff0009)); // 0xfff7 is stored in 'unsigned int' // but: - ASSERT(-1 * 65527 == -65527); // 65527 (== 0xfff7) is stored in 'signed long' + ASSERT(-1 * 65527 == -65527); // 65527 (== 0xfff7) is stored in 'signed LONG' ASSERT(-1 * 33000 == -33000); ASSERT(1 * 10000 * is8 == (sizeof(int) == 2 ? 14464 : 80000)); /* int */ - ASSERT(1 * 10000l * is8 == 80000); /* long */ + ASSERT(1 * 10000l * is8 == 80000); /* LONG */ ASSERT(1 * 40000u * is8 == (sizeof(int) == 2 ? 57856u : 320000)); /* unsigned */ - ASSERT(1 * 40000 * is8 == 320000); /* long */ + ASSERT(1 * 40000 * is8 == 320000); /* LONG */ ASSERT(1 * 0x4000 * is8 == (sizeof(int) == 2 ? 0 : 0x20000)); /* unsigned */ ASSERT(-1 * 1 < 0); @@ -87,19 +94,19 @@ testOpOp(void) ASSERT(uc * (unsigned char ) 0xfffffff7 == 0xef48); us = (unsigned short) 0xfffffff8; ASSERT(us * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 0x0048 : 0xffef0048)); - ul = (unsigned long ) 0xfffffff8; - ASSERT(ul * (unsigned long ) 0xfffffff7 == 0x0048); - ul = (unsigned long ) 0xfffffff8; + ul = (unsigned LONG ) 0xfffffff8; + ASSERT(ul * (unsigned LONG ) 0xfffffff7 == 0x0048); + ul = (unsigned LONG ) 0xfffffff8; ASSERT((stype ) 0xfffffff8 * (stype ) 0xfffffff7 == 72); ASSERT((signed char ) -1 * (unsigned char ) 0xfffffff7 == (sizeof(int) == 2 ? 0xff09 : 0xffffff09)); ASSERT((signed short) -1 * (unsigned short) 0xfffffff7 == (sizeof(int) == 2 ? 9u : 0xffff0009)); - ASSERT((signed long ) -1 * (unsigned long ) 0xfffffff7 == 9u); + ASSERT((signed LONG ) -1 * (unsigned LONG ) 0xfffffff7 == 9u); ASSERT((signed char ) -2 * (unsigned char ) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffffff8)); ASSERT((signed short) -2 * (unsigned short) 0x8004 == (sizeof(int) == 2 ? 0xfff8 : 0xfffefff8)); - ASSERT((signed long ) -2 * (unsigned long ) 0x8004 == 0xfffefff8); + ASSERT((signed LONG ) -2 * (unsigned LONG ) 0x8004 == 0xfffefff8); -- 2.30.2