summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6ea371e)
* src/SDCCast.c (getLeftResultType): 255 fits in char, not 256
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4022
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2006-01-20 Bernhard Held <bernhard AT bernhardheld.de>
+
+ * src/SDCCicode.c (geniCodeAdd, geniCodeArray): use char for array
+ offset if possible
+ * src/SDCCast.c (getLeftResultType): 255 fits in char, not 256
+
2006-01-18 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCast.c (backPatchLabels): fixed bug #1408066: made it
2006-01-18 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCast.c (backPatchLabels): fixed bug #1408066: made it
case '[':
if (!IS_ARRAY (LTYPE (tree)))
return resultType;
case '[':
if (!IS_ARRAY (LTYPE (tree)))
return resultType;
- if (DCL_ELEM (LTYPE (tree)) > 0 && DCL_ELEM (LTYPE (tree)) <= 256)
+ if (DCL_ELEM (LTYPE (tree)) > 0 && DCL_ELEM (LTYPE (tree)) <= 255)
return RESULT_TYPE_CHAR;
return resultType;
default:
return RESULT_TYPE_CHAR;
return resultType;
default:
size = operandFromLit (getSize (ltype->next));
SPEC_USIGN (getSpec (operandType (size))) = 1;
indexUnsigned = IS_UNSIGNED (getSpec (operandType (right)));
size = operandFromLit (getSize (ltype->next));
SPEC_USIGN (getSpec (operandType (size))) = 1;
indexUnsigned = IS_UNSIGNED (getSpec (operandType (right)));
- right = geniCodeMultiply (right,
- size,
- (getArraySizePtr(left) >= INTSIZE) ?
- RESULT_TYPE_INT :
- RESULT_TYPE_CHAR);
+ right = geniCodeMultiply (right, size, resultType);
/* 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: */
/* 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: */
operand *size;
sym_link *ltype = operandType (left);
bool indexUnsigned;
operand *size;
sym_link *ltype = operandType (left);
bool indexUnsigned;
+ RESULT_TYPE resultType;
+
+ resultType = (getArraySizePtr(left) >= INTSIZE) ? RESULT_TYPE_INT : RESULT_TYPE_CHAR;
+ if (DCL_ELEM (ltype))
+ {
+ if (DCL_ELEM (ltype) * getSize (ltype->next) <= 255)
+ resultType = RESULT_TYPE_CHAR;
+ }
left = geniCodeRValue (left, FALSE);
}
left = geniCodeRValue (left, FALSE);
}
- return geniCodeDerefPtr (geniCodeAdd (left,
- right,
- (getArraySizePtr(left) >= INTSIZE) ?
- RESULT_TYPE_INT :
- RESULT_TYPE_CHAR,
- lvl),
+ return geniCodeDerefPtr (geniCodeAdd (left, right, resultType, lvl),
lvl);
}
size = operandFromLit (getSize (ltype->next));
SPEC_USIGN (getSpec (operandType (size))) = 1;
indexUnsigned = IS_UNSIGNED (getSpec (operandType (right)));
lvl);
}
size = operandFromLit (getSize (ltype->next));
SPEC_USIGN (getSpec (operandType (size))) = 1;
indexUnsigned = IS_UNSIGNED (getSpec (operandType (right)));
- right = geniCodeMultiply (right,
- size,
- (getArraySizePtr(left) >= INTSIZE) ?
- RESULT_TYPE_INT :
- RESULT_TYPE_CHAR);
+ right = geniCodeMultiply (right, size, resultType);
/* 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)
/* 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)