From: bernhardheld Date: Mon, 19 Jan 2004 21:28:38 +0000 (+0000) Subject: * src/SDCCicode.c (geniCodeArray): applied patch from Stas Sergeev proposed in FR... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=400a10f587fa3d37986233200e77ce1f3e21fd74;hp=fb4770d8a18c085390904132e346caf2d9a72c9f;p=fw%2Fsdcc * src/SDCCicode.c (geniCodeArray): applied patch from Stas Sergeev proposed in FR #877103 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3140 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 56c03838..dab482aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-01-19 Bernhard Held + + * src/SDCCicode.c (geniCodeArray): applied patch from Stas Sergeev + proposed in FR #877103 + 2004-01-18 Bernhard Held * src/SDCCval.c (cheapestVal): added missing checks diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 8671e2ad..48cc6eab 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2307,6 +2307,7 @@ operand * geniCodeArray (operand * left, operand * right,int lvl) { iCode *ic; + operand *size; sym_link *ltype = operandType (left); bool indexUnsigned; @@ -2319,9 +2320,10 @@ geniCodeArray (operand * left, operand * right,int lvl) return geniCodeDerefPtr (geniCodeAdd (left, right, lvl), lvl); } + size = operandFromLit (getSize (ltype->next)); + SPEC_USIGN (getSpec (operandType (size))) = 1; indexUnsigned = IS_UNSIGNED (getSpec (operandType (right))); - right = geniCodeMultiply (right, - operandFromLit (getSize (ltype->next)), (getArraySizePtr(left) >= INTSIZE)); + right = geniCodeMultiply (right, size, (getArraySizePtr(left) >= INTSIZE)); /* Even if right is a 'unsigned char', the result will be a 'signed int' due to the promotion rules. It doesn't make sense when accessing arrays, so let's fix it here: */ if (indexUnsigned)