From: michaelh Date: Sat, 13 Oct 2001 17:50:10 +0000 (+0000) Subject: * src/SDCCval.c (constVal): Fixed usage of 'L' modifier problems on ppc. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=f760fda1275f579b0ad76473b287533a4448bdc7;p=fw%2Fsdcc * src/SDCCval.c (constVal): Fixed usage of 'L' modifier problems on ppc. * support/regression/tests/longor.c: Added. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1395 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index c8b25d8c..e7abfd35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-10-13 Michael Hope + + * src/SDCCval.c (constVal): Fixed usage of 'L' modifier problems on ppc. + + * support/regression/tests/longor.c: Added. + 2001-10-11 Bernhard Held * as/mcs51/asdata.c: replaced FILENAME_MAX with PATH_MAX diff --git a/src/SDCCval.c b/src/SDCCval.c index 6d645ee2..cee4dde1 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -436,10 +436,6 @@ value *constVal (char *s) SPEC_NOUN (val->type) = V_CHAR; SPEC_USIGN (val->type) = 1; - /* set the _long flag if 'lL' is found */ - if (strchr (s, 'l') || strchr (s, 'L')) - SPEC_LONG (val->type) = 1; - hex = ((strchr (s, 'x') || strchr (s, 'X')) ? 1 : 0); /* set the octal flag */ @@ -463,14 +459,17 @@ value *constVal (char *s) sscanf (s, scanFmt, &sval); + /* Setup the flags first */ + /* set the _long flag if 'lL' is found */ + if (strchr (s, 'l') || strchr (s, 'L')) + SPEC_LONG (val->type) = 1; + if (sval<0) { // "-28u" will still be signed and negative SPEC_USIGN (val->type) = 0; if (sval<-32768) { // check if we have to promote to long SPEC_NOUN (val->type) = V_INT; SPEC_LONG (val->type) = 1; - SPEC_CVAL (val->type).v_long=sval; } else { - SPEC_CVAL (val->type).v_int=sval; if (sval<-128) { // check if we have to promote to int SPEC_NOUN (val->type) = V_INT; } @@ -479,15 +478,36 @@ value *constVal (char *s) if (sval>0xffff) { // check if we have to promote to long SPEC_NOUN (val->type) = V_INT; SPEC_LONG (val->type) = 1; - SPEC_CVAL (val->type).v_ulong=sval; } else { - SPEC_CVAL (val->type).v_uint=sval; if (sval>0xff) { // check if we have to promote to int SPEC_NOUN (val->type) = V_INT; } } } + if (SPEC_LONG (val->type)) + { + if (SPEC_USIGN (val->type)) + { + SPEC_CVAL (val->type).v_ulong = sval; + } + else + { + SPEC_CVAL (val->type).v_long = sval; + } + } + else + { + if (SPEC_USIGN (val->type)) + { + SPEC_CVAL (val->type).v_uint = sval; + } + else + { + SPEC_CVAL (val->type).v_int = sval; + } + } + return val; }