From: johanknol Date: Fri, 14 Dec 2001 16:05:18 +0000 (+0000) Subject: remove the bad fix for bug #485514 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a0548ee32fc0cb59d506ba4d29f7c25c0fae35ae;p=fw%2Fsdcc remove the bad fix for bug #485514 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1675 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCicode.c b/src/SDCCicode.c index c2feabde..28cef7ab 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -1581,15 +1581,15 @@ usualUnaryConversions (operand * op) /* perform "usual binary conversions" */ /*-----------------------------------------------------------------*/ sym_link * -usualBinaryConversions (operand ** op1, operand ** op2, int implicit) +usualBinaryConversions (operand ** op1, operand ** op2) { sym_link *ctype; sym_link *rtype = operandType (*op2); sym_link *ltype = operandType (*op1); ctype = computeType (ltype, rtype); - *op1 = geniCodeCast (ctype, *op1, implicit); - *op2 = geniCodeCast (ctype, *op2, implicit); + *op1 = geniCodeCast (ctype, *op1, TRUE); + *op2 = geniCodeCast (ctype, *op2, TRUE); return ctype; } @@ -1686,9 +1686,7 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) if (!IS_PTR(optype) && !IS_FUNC(optype) && !IS_AGGREGATE(optype)) { // from a non pointer if (IS_INTEGRAL(optype)) { // maybe this is NULL, than it's ok. - // !implicit is always ok, e.g. "(char *) = (char *) + 3;" - if (implicit && - !(IS_LITERAL(optype) && (SPEC_CVAL(optype).v_ulong ==0))) { + if (!(IS_LITERAL(optype) && (SPEC_CVAL(optype).v_ulong ==0))) { if (!TARGET_IS_Z80 && !TARGET_IS_GBZ80 && IS_GENPTR(type)) { // no way to set the storage if (IS_LITERAL(optype)) { @@ -1698,7 +1696,7 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) werror(E_NONPTR2_GENPTR); errors++; } - } else { + } else if (implicit) { werror(W_INTEGRAL2PTR_NOCAST); errors++; } @@ -1818,7 +1816,7 @@ geniCodeMultiply (operand * left, operand * right,int resultIsInt) p2 = powof2 ((unsigned long) floatFromVal (right->operand.valOperand)); } - resType = usualBinaryConversions (&left, &right, TRUE); + resType = usualBinaryConversions (&left, &right); #if 1 rtype = operandType (right); retype = getSpec (rtype); @@ -1875,7 +1873,7 @@ geniCodeDivision (operand * left, operand * right) sym_link *ltype = operandType (left); sym_link *letype = getSpec (ltype); - resType = usualBinaryConversions (&left, &right, TRUE); + resType = usualBinaryConversions (&left, &right); /* if the right is a literal & power of 2 */ /* then make it a right shift */ @@ -1912,7 +1910,7 @@ geniCodeModulus (operand * left, operand * right) return operandFromValue (valMod (left->operand.valOperand, right->operand.valOperand)); - resType = usualBinaryConversions (&left, &right, TRUE); + resType = usualBinaryConversions (&left, &right); /* now they are the same size */ ic = newiCode ('%', left, right); @@ -1986,7 +1984,7 @@ geniCodeSubtract (operand * left, operand * right) } else { /* make them the same size */ - resType = usualBinaryConversions (&left, &right, TRUE); + resType = usualBinaryConversions (&left, &right); } ic = newiCode ('-', left, right); @@ -2006,7 +2004,7 @@ geniCodeSubtract (operand * left, operand * right) /* geniCodeAdd - generates iCode for addition */ /*-----------------------------------------------------------------*/ operand * -geniCodeAdd (operand * left, operand * right, int lvl, int ptrMath) +geniCodeAdd (operand * left, operand * right, int lvl) { iCode *ic; sym_link *resType; @@ -2027,8 +2025,8 @@ geniCodeAdd (operand * left, operand * right, int lvl, int ptrMath) if (IS_LITERAL (letype) && left->isLiteral && !floatFromVal (valFromType (letype))) return right; - /* if left is an array or pointer then size */ - if (ptrMath && IS_PTR (ltype)) + /* if left is a pointer then size */ + if (IS_PTR (ltype)) { isarray = left->isaddr; // there is no need to multiply with 1 @@ -2040,7 +2038,7 @@ geniCodeAdd (operand * left, operand * right, int lvl, int ptrMath) } else { // make them the same size - resType = usualBinaryConversions (&left, &right, FALSE); + resType = usualBinaryConversions (&left, &right); } /* if they are both literals then we know */ @@ -2139,7 +2137,7 @@ geniCodeArray (operand * left, operand * right,int lvl) { left = geniCodeRValue (left, FALSE); } - return geniCodeDerefPtr (geniCodeAdd (left, right, lvl, 1), lvl); + return geniCodeDerefPtr (geniCodeAdd (left, right, lvl), lvl); } right = geniCodeMultiply (right, @@ -2594,7 +2592,7 @@ geniCodeLogic (operand * left, operand * right, int op) OP_VALUE(right), "compare operation", 1); } - ctype = usualBinaryConversions (&left, &right, TRUE); + ctype = usualBinaryConversions (&left, &right); ic = newiCode (op, left, right); IC_RESULT (ic) = newiTempOperand (newCharLink (), 1); @@ -3466,7 +3464,7 @@ ast2iCode (ast * tree,int lvl) case '+': if (right) return geniCodeAdd (geniCodeRValue (left, FALSE), - geniCodeRValue (right, FALSE),lvl, 0); + geniCodeRValue (right, FALSE),lvl); else return geniCodeRValue (left, FALSE); /* unary '+' has no meaning */ @@ -3556,7 +3554,7 @@ ast2iCode (ast * tree,int lvl) return geniCodeAssign (left, geniCodeAdd (geniCodeRValue (operandFromOperand (left), FALSE), - right,lvl,1), 0); + right,lvl), 0); } case SUB_ASSIGN: {