From: bernhardheld Date: Wed, 6 Aug 2003 12:28:56 +0000 (+0000) Subject: * src/SDCCval.c (cheapestVal): changed behaviour to the same as constVal() X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=241274a93ff7f0382230e095be7bc21b49411567;p=fw%2Fsdcc * src/SDCCval.c (cheapestVal): changed behaviour to the same as constVal() * device/lib/time.c: fixed warning "integer overflow in expression" git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2812 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index bfb61192..a8adad0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-08-06 Bernhard Held + + * src/SDCCval.c (cheapestVal): changed behaviour to the same as constVal() + * device/lib/time.c: fixed warning "integer overflow in expression" + 2003-08-05 Bernhard Held * src/SDCCval.c (cheapestVal, valueFromLit): use TYPE_* types diff --git a/device/lib/time.c b/device/lib/time.c index 5d6f45fe..8cb00d1f 100755 --- a/device/lib/time.c +++ b/device/lib/time.c @@ -176,25 +176,25 @@ time_t mktime(struct tm *timeptr) { CheckTime(timeptr); // seconds from 1970 till 1 jan 00:00:00 this year - seconds= (year-1970)*60*60*24*365; + seconds= (year-1970)*(60*60*24L*365); // add extra days for leap years for (i=1970; itm_mday-1*60*60*24; + seconds+= timeptr->tm_mday-1*60*60*24L; seconds+= timeptr->tm_hour*60*60; seconds+= timeptr->tm_min*60; seconds+= timeptr->tm_sec; diff --git a/src/SDCCicode.c b/src/SDCCicode.c index f7f9f89e..d3b62981 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1062,6 +1062,10 @@ operandOperation (operand * left, operand * right, retval = operandFromValue (valCastLiteral (type, operandLitValue (left) * operandLitValue (right))); + if (!options.lessPedantic && + !IS_FLOAT (OP_VALUE(retval)->type) && + !SPEC_LONG (OP_VALUE(retval)->type)) + ; /* TODO: werror (W_INT_OVL) */ break; case '/': if ((TYPE_UDWORD) operandLitValue (right) == 0) diff --git a/src/SDCCval.c b/src/SDCCval.c index 82eec2db..63fac609 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -318,7 +318,7 @@ symbolVal (symbol * sym) /*--------------------------------------------------------------------*/ /* cheapestVal - convert a val to the cheapest as possible value */ /*--------------------------------------------------------------------*/ -value *cheapestVal (value *val) { +static value *cheapestVal (value *val) { TYPE_DWORD sval=0; TYPE_UDWORD uval=0; @@ -357,11 +357,10 @@ value *cheapestVal (value *val) { } } } else { // sval>=0 - SPEC_USIGN(val->type)=1; - if (sval<=65535) { + if (sval<=32767) { SPEC_LONG(val->type)=0; SPEC_CVAL(val->type).v_int = (TYPE_WORD)sval; - if (sval<=255) { + if (sval<=127) { SPEC_NOUN(val->type)=V_CHAR; } } @@ -1044,7 +1043,6 @@ valMult (value * lval, value * rval) { TYPE_UDWORD ul = (TYPE_UWORD) floatFromVal (lval) * (TYPE_UWORD) floatFromVal (rval); - SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) ul; if (!options.lessPedantic) {