From: bernhardheld Date: Sat, 9 Aug 2003 17:18:13 +0000 (+0000) Subject: src/SDCCval.c (valMult): fixex overflow detection of negativ int X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=3ef3e03472b55da1d921c09ad62e21e0f988679b;p=fw%2Fsdcc src/SDCCval.c (valMult): fixex overflow detection of negativ int git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2821 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index c175d63e..7f65ec78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-08-09 Bernhard Held + + * src/SDCCval.c (valMult): fixex overflow detection of negativ int + 2003-08-07 Erik Petrich * src/z80/ralloc.c (joinPushes): made compatible with new signedness diff --git a/src/SDCCval.c b/src/SDCCval.c index 63fac609..62ffcec2 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -1039,10 +1039,11 @@ valMult (value * lval, value * rval) if (SPEC_LONG (val->type)) SPEC_CVAL (val->type).v_ulong = (TYPE_UDWORD) floatFromVal (lval) * (TYPE_UDWORD) floatFromVal (rval); - else + else /* int */ { TYPE_UDWORD ul = (TYPE_UWORD) floatFromVal (lval) * (TYPE_UWORD) floatFromVal (rval); + SPEC_CVAL (val->type).v_uint = (TYPE_UWORD) ul; if (!options.lessPedantic) { @@ -1053,7 +1054,10 @@ valMult (value * lval, value * rval) } else /* signed result */ { - if ((TYPE_DWORD) ul != SPEC_CVAL (val->type).v_int) + TYPE_DWORD l = (TYPE_WORD) floatFromVal (lval) * + (TYPE_WORD) floatFromVal (rval); + + if (l != SPEC_CVAL (val->type).v_int) werror (W_INT_OVL); } }