X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCsymt.c;h=dcce5fcc763cb0fa810479f42b433a818eb23df6;hb=7faa2c7f7e56d31567f05ae41a0c431f9bced6de;hp=4ceceaf007bd50c5a55f08ee18cb4d8d12a879cb;hpb=67613b6eceb41c8a242c2556a0f59311adb0b388;p=fw%2Fsdcc diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 4ceceaf0..dcce5fcc 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1595,7 +1595,8 @@ static sym_link * 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)) { @@ -1660,7 +1661,7 @@ computeTypeOr (sym_link * etype1, sym_link * etype2, sym_link * reType) /*------------------------------------------------------------------*/ 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; @@ -1732,6 +1733,7 @@ computeType (sym_link * type1, sym_link * type2, break; case RESULT_TYPE_INT: case RESULT_TYPE_NONE: + case RESULT_TYPE_OTHER: if (IS_BIT (reType)) { SPEC_NOUN (reType) = V_CHAR; @@ -1758,7 +1760,16 @@ computeType (sym_link * type1, sym_link * type2, 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; @@ -1904,7 +1915,12 @@ compareType (sym_link * dest, sym_link * src) { 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;