+2003-08-06 Bernhard Held <bernhard@bernhardheld.de>
+
+ * 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 <bernhard@bernhardheld.de>
* src/SDCCval.c (cheapestVal, valueFromLit): use TYPE_* types
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; i<year; i++) {
if (LEAP_YEAR(i)) {
- seconds+= 60*60*24;
+ seconds+= 60*60*24L;
}
}
// add days for this year
for (i=0; i<month; i++) {
if (i==1 && LEAP_YEAR(year)) {
- seconds+= 60*60*24*29;
+ seconds+= 60*60*24L*29;
} else {
- seconds+= 60*60*24*monthDays[i];
+ seconds+= 60*60*24L*monthDays[i];
}
}
- seconds+= timeptr->tm_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;
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)
/*--------------------------------------------------------------------*/
/* 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;
}
}
} 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;
}
}
{
TYPE_UDWORD ul = (TYPE_UWORD) floatFromVal (lval) *
(TYPE_UWORD) floatFromVal (rval);
-
SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) ul;
if (!options.lessPedantic)
{