X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCicode.c;h=a94d664f9d2e9aaea0fdbd3e9d4971d3be984a30;hb=46adfcf4c3d151aa4c5d5c4e8df46e6851f927e4;hp=4ee005545ba7f2bc5a1f51defee057d39e6da3df;hpb=a27e7a4d14e0da24074864d363eb08700d6893ed;p=fw%2Fsdcc diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 4ee00554..a94d664f 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2058,12 +2058,6 @@ geniCodeAdd (operand * left, operand * right, int lvl) int isarray = 0; LRTYPE; -#if 0 - /* if left is an array then array access */ - if (IS_ARRAY (ltype)) - return geniCodeArray (left, right,lvl); -#endif - /* if the right side is LITERAL zero */ /* return the left side */ if (IS_LITERAL (retype) && right->isLiteral && !floatFromVal (valFromType (retype))) @@ -2531,16 +2525,19 @@ geniCodeDerefPtr (operand * op,int lvl) sym_link *rtype, *retype; sym_link *optype = operandType (op); - /* if this is a pointer then generate the rvalue */ - if (IS_PTR (optype)) + // if this is an array then array access + if (IS_ARRAY (optype)) { + // don't worry, this will be optimized out later + return geniCodeArray (op, operandFromLit (0), lvl); + } + + // just in case someone screws up + wassert (IS_PTR (optype)); + + if (IS_TRUE_SYMOP (op)) { - if (IS_TRUE_SYMOP (op)) - { - op->isaddr = 1; - op = geniCodeRValue (op, TRUE); - } - else - op = geniCodeRValue (op, TRUE); + op->isaddr = 1; + op = geniCodeRValue (op, TRUE); } /* now get rid of the pointer part */ @@ -2553,18 +2550,15 @@ geniCodeDerefPtr (operand * op,int lvl) retype = getSpec (rtype = copyLinkChain (optype->next)); } - /* if this is a pointer then outputclass needs 2b updated */ - if (IS_PTR (optype)) - setOClass (optype, retype); + /* outputclass needs 2b updated */ + setOClass (optype, retype); op->isGptr = IS_GENPTR (optype); -#ifdef JWK /* if the pointer was declared as a constant */ /* then we cannot allow assignment to the derefed */ if (IS_PTR_CONST (optype)) SPEC_CONST (retype) = 1; -#endif op->isaddr = (IS_PTR (rtype) || IS_STRUCT (rtype) ||