computeTypeOr (sym_link * etype1, sym_link * etype2, sym_link * reType)
{
/* sanity check */
- assert (IS_CHAR (etype1) && IS_CHAR (etype2));
+ assert ( (IS_CHAR (etype1) || IS_BIT (etype1))
+ && (IS_CHAR (etype2) || IS_BIT (etype2)));
if (SPEC_USIGN (etype1) == SPEC_USIGN (etype2))
{
/*------------------------------------------------------------------*/
sym_link *
computeType (sym_link * type1, sym_link * type2,
- RESULT_TYPE resultType, char op)
+ RESULT_TYPE resultType, int op)
{
sym_link *rType;
sym_link *reType;
break;
case RESULT_TYPE_INT:
case RESULT_TYPE_NONE:
+ case RESULT_TYPE_OTHER:
if (IS_BIT (reType))
{
SPEC_NOUN (reType) = V_CHAR;
SPEC_USIGN (reType) = 1;
return rType;
}
- else
+ else if (op == '*')
+ {
+ SPEC_NOUN (reType) = V_INT;
+ SPEC_USIGN (reType) = 0;
+ return rType;
+ }
+ /* TODO: should be in SDCCast.c */
+ else if ( op == '/'
+ && ( !SPEC_USIGN (etype1)
+ || !SPEC_USIGN (etype2)))
{
SPEC_NOUN (reType) = V_INT;
SPEC_USIGN (reType) = 0;
{
if (SPEC_USIGN (dest) == SPEC_USIGN (src) &&
IS_INTEGRAL (dest) && IS_INTEGRAL (src) &&
- getSize (dest) == getSize (src))
+ /* I would prefer
+ bitsForType (dest) == bitsForType (src))
+ instead of the next two lines, but the regression tests fail with
+ them; I guess it's a problem with replaceCheaperOp */
+ getSize (dest) == getSize (src) &&
+ !(!IS_BIT (dest) && IS_BIT (src)))
return 1;
else if (IS_ARITHMETIC (dest) && IS_ARITHMETIC (src))
return -1;