From 6f813805bf1e3226d29fab8d46a7a8a46102dbf6 Mon Sep 17 00:00:00 2001 From: johanknol Date: Wed, 25 Jul 2001 19:53:19 +0000 Subject: [PATCH] Don't promote -3 to int either git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1103 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCval.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/SDCCval.c b/src/SDCCval.c index 51214a55..2f5b9710 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -309,31 +309,32 @@ constVal (char *s) else sval = atol (s); - + // check if we have to promote to long if (SPEC_LONG (val->type) || (SPEC_USIGN(val->type) && sval>0xffff) || - (!SPEC_USIGN(val->type) && ((long)sval>32767 || (long)sval<-32768)) { + (!SPEC_USIGN(val->type) && ((long)sval>32767 || (long)sval<-32768))) { if (SPEC_USIGN (val->type)) SPEC_CVAL (val->type).v_ulong = sval; else SPEC_CVAL (val->type).v_long = sval; SPEC_LONG (val->type) = 1; + return val; } + + if (SPEC_USIGN (val->type)) + SPEC_CVAL (val->type).v_uint = sval; else - { - if (SPEC_USIGN (val->type)) - SPEC_CVAL (val->type).v_uint = sval; - else - SPEC_CVAL (val->type).v_int = sval; - } - - // check the size and make it a char if possible - if (sval < 256) + SPEC_CVAL (val->type).v_int = sval; + + + // check if we can make it a char + if ((SPEC_USIGN(val->type) && sval < 256) || + (!SPEC_USIGN(val->type) && ((long)sval<127 && (long)sval>-128))) { SPEC_NOUN (val->etype) = V_CHAR; - + } return val; - } + /*! /fn char hexEscape(char **src) /param src Pointer to 'x' from start of hex character value -- 2.39.5