X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCicode.c;h=381a2bcb68800c04c9c113714d324b0adfc808ef;hb=7509c54acfc8ec99fc043d3717dad8e338dabc7f;hp=9637d52dd11313e42b2129658c337727efd3e67e;hpb=59649e00927d0db09488038b2eb7543bbe0f2214;p=fw%2Fsdcc diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 9637d52d..381a2bcb 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -38,6 +38,7 @@ char *filename; int lineno; int block; int scopeLevel; +int seqPoint; symbol *returnLabel; /* function return label */ symbol *entryLabel; /* function entry label */ @@ -46,12 +47,13 @@ symbol *entryLabel; /* function entry label */ /* forward definition of some functions */ operand *geniCodeDivision (operand *, operand *); operand *geniCodeAssign (operand *, operand *, int); -operand *geniCodeArray (operand *, operand *,int); -operand *geniCodeArray2Ptr (operand *); +static operand *geniCodeArray (operand *, operand *,int); +static operand *geniCodeArray2Ptr (operand *); operand *geniCodeRValue (operand *, bool); operand *geniCodeDerefPtr (operand *,int); int isLvaluereq(int lvl); void setOClass (sym_link * ptr, sym_link * spec); +static operand *geniCodeCast (sym_link *, operand *, bool); #define PRINTFUNC(x) void x (FILE *of, iCode *ic, char *s) /* forward definition of ic print functions */ @@ -143,14 +145,14 @@ void checkConstantRange(sym_link *ltype, value *val, char *msg, max = pow ((double)2.0, (double)bitsForType(ltype)); - if (SPEC_LONG(val->type)) { - if (SPEC_USIGN(val->type)) { + if (IS_LONG(val->type)) { + if (IS_UNSIGNED(val->type)) { v=SPEC_CVAL(val->type).v_ulong; } else { v=SPEC_CVAL(val->type).v_long; } } else { - if (SPEC_USIGN(val->type)) { + if (IS_UNSIGNED(val->type)) { v=SPEC_CVAL(val->type).v_uint; } else { v=SPEC_CVAL(val->type).v_int; @@ -164,21 +166,21 @@ void checkConstantRange(sym_link *ltype, value *val, char *msg, pedantic=2; #endif - if (SPEC_NOUN(ltype)==FLOAT) { + if (IS_FLOAT(ltype)) { // anything will do return; } - if (!SPEC_USIGN(val->type) && v<0) { + if (!IS_UNSIGNED(val->type) && v<0) { negative=1; - if (SPEC_USIGN(ltype) && (pedantic>1)) { + if (IS_UNSIGNED(ltype) && (pedantic>1)) { warnings++; } v=-v; } // if very pedantic: "char c=200" is not allowed - if (pedantic>1 && !SPEC_USIGN(ltype)) { + if (pedantic>1 && !IS_UNSIGNED(ltype)) { max = max/2 + negative; } @@ -189,7 +191,7 @@ void checkConstantRange(sym_link *ltype, value *val, char *msg, #if 0 // temporary disabled, leaving the warning as a reminder if (warnings) { SNPRINTF (message, sizeof(message), "for %s %s in %s", - SPEC_USIGN(ltype) ? "unsigned" : "signed", + IS_UNSIGNED(ltype) ? "unsigned" : "signed", nounName(ltype), msg); werror (W_CONST_RANGE, message); @@ -221,7 +223,7 @@ printOperand (operand * op, FILE * file) case VALUE: opetype = getSpec (operandType (op)); - if (SPEC_NOUN (opetype) == V_FLOAT) + if (IS_FLOAT (opetype)) fprintf (file, "%g {", SPEC_CVAL (opetype).v_float); else fprintf (file, "0x%x {", (unsigned) floatFromVal (op->operand.valOperand)); @@ -572,6 +574,7 @@ newiCode (int op, operand * left, operand * right) ic = Safe_alloc ( sizeof (iCode)); + ic->seqPoint = seqPoint; ic->lineno = lineno; ic->filename = filename; ic->block = block; @@ -1063,7 +1066,7 @@ iCode *getBuiltinParms (iCode *ic, int *pcount, operand **parms) ic = ic->next; (*pcount)++; } - + ic->generated = 1; /* make sure this is a builtin function call */ assert(IS_SYMOP(IC_LEFT(ic))); @@ -1121,14 +1124,14 @@ operandOperation (operand * left, operand * right, !IS_SPEC (type)) { /* long is handled here, because it can overflow with double */ - if (SPEC_LONG (type) || + if (IS_LONG (type) || !IS_SPEC (type)) /* signed and unsigned mul are the same, as long as the precision of the result isn't bigger than the precision of the operands. */ retval = operandFromValue (valCastLiteral (type, (TYPE_UDWORD) operandLitValue (left) * (TYPE_UDWORD) operandLitValue (right))); - else if (SPEC_USIGN (type)) /* unsigned int */ + else if (IS_UNSIGNED (type)) /* unsigned int */ { /* unsigned int is handled here in order to detect overflow */ TYPE_UDWORD ul = (TYPE_UWORD) operandLitValue (left) * @@ -1163,23 +1166,35 @@ operandOperation (operand * left, operand * right, } else - retval = operandFromValue (valCastLiteral (type, - operandLitValue (left) / - operandLitValue (right))); + { + if (IS_UNSIGNED (type)) + { + SPEC_USIGN (let) = 1; + SPEC_USIGN (ret) = 1; + retval = operandFromValue (valCastLiteral (type, + (TYPE_UDWORD) operandLitValue (left) / + (TYPE_UDWORD) operandLitValue (right))); + } + else + { + retval = operandFromValue (valCastLiteral (type, + operandLitValue (left) / + operandLitValue (right))); + } + } break; case '%': - if ((TYPE_UDWORD) operandLitValue (right) == 0) { + if ((TYPE_UDWORD) operandLitValue (right) == 0) + { werror (E_DIVIDE_BY_ZERO); retval = right; - } + } else { - if (SPEC_USIGN(let) || SPEC_USIGN(ret)) - /* one of the operands is unsigned */ + if (IS_UNSIGNED (type)) retval = operandFromLit ((TYPE_UDWORD) operandLitValue (left) % (TYPE_UDWORD) operandLitValue (right)); else - /* both operands are signed */ retval = operandFromLit ((TYPE_DWORD) operandLitValue (left) % (TYPE_DWORD) operandLitValue (right)); } @@ -1187,13 +1202,14 @@ operandOperation (operand * left, operand * right, case LEFT_OP: /* The number of left shifts is always unsigned. Signed doesn't make sense here. Shifting by a negative number is impossible. */ - retval = operandFromLit ((TYPE_UDWORD) operandLitValue (left) << - (TYPE_UDWORD) operandLitValue (right)); + retval = operandFromValue (valCastLiteral (type, + ((TYPE_UDWORD) operandLitValue (left) << + (TYPE_UDWORD) operandLitValue (right)))); break; case RIGHT_OP: /* The number of right shifts is always unsigned. Signed doesn't make sense here. Shifting by a negative number is impossible. */ - if (SPEC_USIGN(let)) + if (IS_UNSIGNED(let)) /* unsigned: logic shift right */ retval = operandFromLit ((TYPE_UDWORD) operandLitValue (left) >> (TYPE_UDWORD) operandLitValue (right)); @@ -1208,14 +1224,14 @@ operandOperation (operand * left, operand * right, TYPE_UDWORD l, r; l = (TYPE_UDWORD) operandLitValue (left); - if (SPEC_NOUN(OP_VALUE(left)->type) == V_CHAR) + if (IS_CHAR(OP_VALUE(left)->type)) l &= 0xff; - else if (!SPEC_LONG (OP_VALUE(left)->type)) + else if (!IS_LONG (OP_VALUE(left)->type)) l &= 0xffff; r = (TYPE_UDWORD) operandLitValue (right); - if (SPEC_NOUN(OP_VALUE(right)->type) == V_CHAR) + if (IS_CHAR(OP_VALUE(right)->type)) r &= 0xff; - else if (!SPEC_LONG (OP_VALUE(right)->type)) + else if (!IS_LONG (OP_VALUE(right)->type)) r &= 0xffff; retval = operandFromLit (l == r); } @@ -1426,7 +1442,7 @@ operandFromOperand (operand * op) nop->isLiteral = op->isLiteral; nop->usesDefs = op->usesDefs; nop->isParm = op->isParm; - + switch (nop->type) { case SYMBOL: @@ -1517,6 +1533,7 @@ operandFromSymbol (symbol * sym) and before liveRange calculation */ sym->reqv = newiTempOperand (sym->type, 0); sym->reqv->key = sym->key; + OP_SYMBOL (sym->reqv)->prereqv = sym; OP_SYMBOL (sym->reqv)->key = sym->key; OP_SYMBOL (sym->reqv)->isreqv = 1; OP_SYMBOL (sym->reqv)->islocal = 1; @@ -1717,7 +1734,8 @@ getArraySizePtr (operand * op) /*-----------------------------------------------------------------*/ /* perform "usual unary conversions" */ /*-----------------------------------------------------------------*/ -operand * +#if 0 +static operand * usualUnaryConversions (operand * op) { if (IS_INTEGRAL (operandType (op))) @@ -1730,22 +1748,41 @@ usualUnaryConversions (operand * op) } return op; } +#endif /*-----------------------------------------------------------------*/ /* perform "usual binary conversions" */ /*-----------------------------------------------------------------*/ -sym_link * -usualBinaryConversions (operand ** op1, operand ** op2) +static sym_link * +usualBinaryConversions (operand ** op1, operand ** op2, + bool promoteCharToInt, bool isMul) { sym_link *ctype; sym_link *rtype = operandType (*op2); sym_link *ltype = operandType (*op1); - - ctype = computeType (ltype, rtype); + ctype = computeType (ltype, rtype, promoteCharToInt); + + /* special for multiplication: + This if for 'mul a,b', which takes two chars and returns an int */ + if ( isMul + /* && promoteCharToInt superfluous, already handled by computeType() */ + && IS_INT (getSpec (ctype))) + { + sym_link *retype = getSpec (rtype); + sym_link *letype = getSpec (ltype); + + if ( IS_CHAR (letype) + && IS_CHAR (retype) + && IS_UNSIGNED (letype) + && IS_UNSIGNED (retype)) + { + return ctype; + } + } *op1 = geniCodeCast (ctype, *op1, TRUE); *op2 = geniCodeCast (ctype, *op2, TRUE); - + return ctype; } @@ -1810,7 +1847,7 @@ geniCodeRValue (operand * op, bool force) /*-----------------------------------------------------------------*/ /* geniCodeCast - changes the value from one type to another */ /*-----------------------------------------------------------------*/ -operand * +static operand * geniCodeCast (sym_link * type, operand * op, bool implicit) { iCode *ic; @@ -1826,20 +1863,28 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) return op; } + if (IS_ITEMP (op) && IS_ARRAY (OP_SYMBOL (op)->type)) + { + geniCodeArray2Ptr (op); + op->isaddr = 0; + } + /* if the operand is already the desired type then do nothing */ if (compareType (type, optype) == 1) return op; /* if this is a literal then just change the type & return */ if (IS_LITERAL (opetype) && op->type == VALUE && !IS_PTR (type) && !IS_PTR (optype)) - return operandFromValue (valCastLiteral (type, - operandLitValue (op))); + { + return operandFromValue (valCastLiteral (type, + operandLitValue (op))); + } /* if casting to/from pointers, do some checking */ if (IS_PTR(type)) { // to a pointer 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. + if (IS_INTEGRAL(optype)) { + // maybe this is NULL, than it's ok. if (!(IS_LITERAL(optype) && (SPEC_CVAL(optype).v_ulong ==0))) { if (port->s.gptr_size > port->s.fptr_size && IS_GENPTR(type)) { // no way to set the storage @@ -1855,9 +1900,9 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) errors++; } } - } else { + } else { // shouldn't do that with float, array or structure unless to void - if (!IS_VOID(getSpec(type)) && + if (!IS_VOID(getSpec(type)) && !(IS_CODEPTR(type) && IS_FUNC(type->next) && IS_FUNC(optype))) { werror(E_INCOMPAT_TYPES); errors++; @@ -1867,7 +1912,7 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) if (port->s.gptr_size > port->s.fptr_size /*!TARGET_IS_Z80 && !TARGET_IS_GBZ80*/) { // if not a pointer to a function if (!(IS_CODEPTR(type) && IS_FUNC(type->next) && IS_FUNC(optype))) { - if (implicit) { // if not to generic, they have to match + if (implicit) { // if not to generic, they have to match if ((!IS_GENPTR(type) && (DCL_TYPE(optype) != DCL_TYPE(type)))) { werror(E_INCOMPAT_PTYPES); errors++; @@ -1894,6 +1939,14 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) } /* if they are the same size create an assignment */ + + /* This seems very dangerous to me, since there are several */ + /* optimizations (for example, gcse) that don't notice the */ + /* cast hidden in this assignement and may simplify an */ + /* iCode to use the original (uncasted) operand. */ + /* Unfortunately, other things break when this cast is */ + /* made explicit. Need to fix this someday. */ + /* -- EEP, 2004/01/21 */ if (getSize (type) == getSize (optype) && !IS_BITFIELD (type) && !IS_FLOAT (type) && @@ -1901,11 +1954,10 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) ((IS_SPEC (type) && IS_SPEC (optype)) || (!IS_SPEC (type) && !IS_SPEC (optype)))) { - ic = newiCode ('=', NULL, op); IC_RESULT (ic) = newiTempOperand (type, 0); SPIL_LOC (IC_RESULT (ic)) = - (IS_TRUE_SYMOP (op) ? OP_SYMBOL (op) : NULL); + (IS_TRUE_SYMOP (op) ? OP_SYMBOL (op) : NULL); IC_RESULT (ic)->isaddr = 0; } else @@ -1930,7 +1982,7 @@ geniCodeCast (sym_link * type, operand * op, bool implicit) /*-----------------------------------------------------------------*/ /* geniCodeLabel - will create a Label */ /*-----------------------------------------------------------------*/ -void +void geniCodeLabel (symbol * label) { iCode *ic; @@ -1942,7 +1994,7 @@ geniCodeLabel (symbol * label) /*-----------------------------------------------------------------*/ /* geniCodeGoto - will create a Goto */ /*-----------------------------------------------------------------*/ -void +void geniCodeGoto (symbol * label) { iCode *ic; @@ -1955,7 +2007,7 @@ geniCodeGoto (symbol * label) /* geniCodeMultiply - gen intermediate code for multiplication */ /*-----------------------------------------------------------------*/ operand * -geniCodeMultiply (operand * left, operand * right,int resultIsInt) +geniCodeMultiply (operand * left, operand * right, int resultIsInt) { iCode *ic; int p2 = 0; @@ -1968,20 +2020,16 @@ geniCodeMultiply (operand * left, operand * right,int resultIsInt) right->operand.valOperand)); if (IS_LITERAL(retype)) { - p2 = powof2 ((unsigned long) floatFromVal (right->operand.valOperand)); + p2 = powof2 ((TYPE_UDWORD) floatFromVal (right->operand.valOperand)); } - resType = usualBinaryConversions (&left, &right); + resType = usualBinaryConversions (&left, &right, resultIsInt, TRUE); #if 1 rtype = operandType (right); retype = getSpec (rtype); ltype = operandType (left); letype = getSpec (ltype); #endif - if (resultIsInt) - { - SPEC_NOUN(getSpec(resType))=V_INT; - } /* if the right is a literal & power of 2 */ /* then make it a left shift */ @@ -2028,15 +2076,17 @@ geniCodeDivision (operand * left, operand * right) sym_link *ltype = operandType (left); sym_link *letype = getSpec (ltype); - resType = usualBinaryConversions (&left, &right); + resType = usualBinaryConversions (&left, &right, + (IS_UNSIGNED (retype) && IS_UNSIGNED (letype)) ? FALSE : TRUE, + FALSE); /* if the right is a literal & power of 2 and left is unsigned then make it a right shift */ if (IS_LITERAL (retype) && !IS_FLOAT (letype) && - SPEC_USIGN(letype) && - (p2 = powof2 ((unsigned long) + IS_UNSIGNED(letype) && + (p2 = powof2 ((TYPE_UDWORD) floatFromVal (right->operand.valOperand)))) { ic = newiCode (RIGHT_OP, left, operandFromLit (p2)); /* right shift */ } @@ -2067,7 +2117,9 @@ geniCodeModulus (operand * left, operand * right) return operandFromValue (valMod (left->operand.valOperand, right->operand.valOperand)); - resType = usualBinaryConversions (&left, &right); + resType = usualBinaryConversions (&left, &right, + (IS_UNSIGNED (retype) && IS_UNSIGNED (letype)) ? FALSE : TRUE, + FALSE); /* now they are the same size */ ic = newiCode ('%', left, right); @@ -2146,7 +2198,7 @@ geniCodeSubtract (operand * left, operand * right) } else { /* make them the same size */ - resType = usualBinaryConversions (&left, &right); + resType = usualBinaryConversions (&left, &right, FALSE, FALSE); } ic = newiCode ('-', left, right); @@ -2172,6 +2224,7 @@ geniCodeAdd (operand * left, operand * right, int lvl) sym_link *resType; operand *size; int isarray = 0; + bool indexUnsigned; LRTYPE; /* if the right side is LITERAL zero */ @@ -2188,15 +2241,23 @@ geniCodeAdd (operand * left, operand * right, int lvl) { isarray = left->isaddr; // there is no need to multiply with 1 - if (getSize(ltype->next)!=1) { - size = operandFromLit (getSize (ltype->next)); - right = geniCodeMultiply (right, size, (getArraySizePtr(left) >= INTSIZE)); - } + if (getSize (ltype->next) != 1) + { + size = operandFromLit (getSize (ltype->next)); + SPEC_USIGN (getSpec (operandType (size))) = 1; + indexUnsigned = IS_UNSIGNED (getSpec (operandType (right))); + 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) + SPEC_USIGN (getSpec (operandType (right))) = 1; + } resType = copyLinkChain (ltype); } else { // make them the same size - resType = usualBinaryConversions (&left, &right); + resType = usualBinaryConversions (&left, &right, FALSE, FALSE); } /* if they are both literals then we know */ @@ -2246,7 +2307,7 @@ aggrToPtr (sym_link * type, bool force) /*-----------------------------------------------------------------*/ /* geniCodeArray2Ptr - array to pointer */ /*-----------------------------------------------------------------*/ -operand * +static operand * geniCodeArray2Ptr (operand * op) { sym_link *optype = operandType (op); @@ -2263,34 +2324,43 @@ geniCodeArray2Ptr (operand * op) /*-----------------------------------------------------------------*/ /* geniCodeArray - array access */ /*-----------------------------------------------------------------*/ -operand * -geniCodeArray (operand * left, operand * right,int lvl) +static operand * +geniCodeArray (operand * left, operand * right, int lvl) { iCode *ic; + operand *size; sym_link *ltype = operandType (left); - + bool indexUnsigned; + if (IS_PTR (ltype)) { if (IS_PTR (ltype->next) && left->isaddr) { left = geniCodeRValue (left, FALSE); } - + return geniCodeDerefPtr (geniCodeAdd (left, right, lvl), lvl); } - - right = geniCodeMultiply (right, - operandFromLit (getSize (ltype->next)), (getArraySizePtr(left) >= INTSIZE)); - + size = operandFromLit (getSize (ltype->next)); + SPEC_USIGN (getSpec (operandType (size))) = 1; + indexUnsigned = IS_UNSIGNED (getSpec (operandType (right))); + 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) + SPEC_USIGN (getSpec (operandType (right))) = 1; /* we can check for limits here */ + /* already done in SDCCast.c if (isOperandLiteral (right) && IS_ARRAY (ltype) && DCL_ELEM (ltype) && (operandLitValue (right) / getSize (ltype->next)) >= DCL_ELEM (ltype)) { - werror (E_ARRAY_BOUND); - right = operandFromLit (0); + werror (W_IDX_OUT_OF_BOUNDS, + (int) operandLitValue (right) / getSize (ltype->next), + DCL_ELEM (ltype)); } + */ ic = newiCode ('+', left, right); @@ -2306,7 +2376,7 @@ geniCodeArray (operand * left, operand * right,int lvl) } /*-----------------------------------------------------------------*/ -/* geniCodeStruct - generates intermediate code for structres */ +/* geniCodeStruct - generates intermediate code for structures */ /*-----------------------------------------------------------------*/ operand * geniCodeStruct (operand * left, operand * right, bool islval) @@ -2777,7 +2847,7 @@ geniCodeLogic (operand * left, operand * right, int op) } } - ctype = usualBinaryConversions (&left, &right); + ctype = usualBinaryConversions (&left, &right, FALSE, FALSE); ic = newiCode (op, left, right); IC_RESULT (ic) = newiTempOperand (newCharLink (), 1); @@ -2975,7 +3045,7 @@ geniCodeSEParms (ast * parms,int lvl) /*-----------------------------------------------------------------*/ value * geniCodeParms (ast * parms, value *argVals, int *stack, - sym_link * fetype, symbol * func,int lvl) + sym_link * ftype, int lvl) { iCode *ic; operand *pval; @@ -2985,14 +3055,14 @@ geniCodeParms (ast * parms, value *argVals, int *stack, if (argVals==NULL) { // first argument - argVals=FUNC_ARGS(func->type); + argVals = FUNC_ARGS (ftype); } /* if this is a param node then do the left & right */ if (parms->type == EX_OP && parms->opval.op == PARAM) { - argVals=geniCodeParms (parms->left, argVals, stack, fetype, func,lvl); - argVals=geniCodeParms (parms->right, argVals, stack, fetype, func,lvl); + argVals=geniCodeParms (parms->left, argVals, stack, ftype, lvl); + argVals=geniCodeParms (parms->right, argVals, stack, ftype, lvl); return argVals; } @@ -3016,18 +3086,18 @@ geniCodeParms (ast * parms, value *argVals, int *stack, } /* if register parm then make it a send */ - if ((IS_REGPARM (parms->etype) && !IFFUNC_HASVARARGS(func->type)) || - IFFUNC_ISBUILTIN(func->type)) + if ((IS_REGPARM (parms->etype) && !IFFUNC_HASVARARGS(ftype)) || + IFFUNC_ISBUILTIN(ftype)) { ic = newiCode (SEND, pval, NULL); ic->argreg = SPEC_ARGREG(parms->etype); - ic->builtinSEND = FUNC_ISBUILTIN(func->type); + ic->builtinSEND = FUNC_ISBUILTIN(ftype); ADDTOCHAIN (ic); } else { /* now decide whether to push or assign */ - if (!(options.stackAuto || IFFUNC_ISREENT (func->type))) + if (!(options.stackAuto || IFFUNC_ISREENT (ftype))) { /* assign */ @@ -3061,6 +3131,7 @@ geniCodeCall (operand * left, ast * parms,int lvl) iCode *ic; operand *result; sym_link *type, *etype; + sym_link *ftype; int stack = 0; if (!IS_FUNC(OP_SYMBOL(left)->type) && @@ -3074,8 +3145,12 @@ geniCodeCall (operand * left, ast * parms,int lvl) of overlaying function parameters */ geniCodeSEParms (parms,lvl); + ftype = operandType (left); + if (IS_CODEPTR (ftype)) + ftype = ftype->next; + /* first the parameters */ - geniCodeParms (parms, NULL, &stack, getSpec (operandType (left)), OP_SYMBOL (left),lvl); + geniCodeParms (parms, NULL, &stack, ftype, lvl); /* now call : if symbol then pcall */ if (IS_OP_POINTER (left) || IS_ITEMP(left)) { @@ -3084,7 +3159,7 @@ geniCodeCall (operand * left, ast * parms,int lvl) ic = newiCode (CALL, left, NULL); } - type = copyLinkChain (operandType (left)->next); + type = copyLinkChain (ftype->next); etype = getSpec (type); SPEC_EXTR (etype) = 0; IC_RESULT (ic) = result = newiTempOperand (type, 1); @@ -3345,7 +3420,7 @@ geniCodeJumpTable (operand * cond, value * caseVals, ast * tree) sym_link *cetype = getSpec (operandType (cond)); /* no need to check the lower bound if the condition is unsigned & minimum value is zero */ - if (!(min == 0 && SPEC_USIGN (cetype))) + if (!(min == 0 && IS_UNSIGNED (cetype))) { boundary = geniCodeLogic (cond, operandFromLit (min), '<'); ic = newiCodeCondition (boundary, falseLabel, NULL); @@ -3465,7 +3540,7 @@ geniCodeInline (ast * tree) /*-----------------------------------------------------------------*/ /* geniCodeArrayInit - intermediate code for array initializer */ /*-----------------------------------------------------------------*/ -static void +static void geniCodeArrayInit (ast * tree, operand *array) { iCode *ic; @@ -3593,6 +3668,8 @@ ast2iCode (ast * tree,int lvl) block = tree->block; if (tree->level) scopeLevel = tree->level; + if (tree->seqPoint) + seqPoint = tree->seqPoint; if (tree->type == EX_VALUE) return operandFromValue (tree->opval.val); @@ -3739,7 +3816,7 @@ ast2iCode (ast * tree,int lvl) return geniCodeDerefPtr (geniCodeRValue (left, FALSE),lvl); case '-': - if (right) + if (right) return geniCodeSubtract (geniCodeRValue (left, FALSE), geniCodeRValue (right, FALSE)); else @@ -3759,11 +3836,11 @@ ast2iCode (ast * tree,int lvl) case RIGHT_OP: return geniCodeRightShift (geniCodeRValue (left, FALSE), geniCodeRValue (right, FALSE)); - case CAST: + case CAST: #if 0 // this indeed needs a second thought { operand *op; - + // let's keep this simple: get the rvalue we need op=geniCodeRValue (right, FALSE); // now cast it to whatever we want @@ -3963,7 +4040,7 @@ ast2iCode (ast * tree,int lvl) return NULL; case CRITICAL: - geniCodeCritical (tree, lvl); + geniCodeCritical (tree, lvl); } return NULL;