From: johanknol Date: Sat, 28 Dec 2002 13:16:48 +0000 (+0000) Subject: fixed the implicit integral promotion as in X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=94b52f30686636001f9c7af9faefa9e0f9a96ddb;p=fw%2Fsdcc fixed the implicit integral promotion as in https://sourceforge.net/forum/message.php?msg_id=1807843 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2123 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index 63a78966..14c2f2d1 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -1959,9 +1959,13 @@ decorateType (ast * tree) if (dtr != tree->right) tree->right = dtr; - /* special case for left shift operation : cast up right->left if type of left + /* special case for some operations: cast up right->left if type of left has greater size than right */ - if (tree->left && tree->right && tree->right->opval.op == LEFT_OP) { + if (tree->left && tree->right && IS_AST_OP(tree->right) && + (tree->right->opval.op == LEFT_OP || + tree->right->opval.op == '*' || // for int -> long only + tree->right->opval.op == '+' || + tree->right->opval.op == '-')) { int lsize = getSize(LTYPE(tree)); int rsize = getSize(RTYPE(tree)); @@ -2392,17 +2396,13 @@ decorateType (ast * tree) } LRVAL (tree) = RRVAL (tree) = 1; + TETYPE (tree) = getSpec (TTYPE (tree) = + computeType (LTYPE (tree), + RTYPE (tree))); /* promote result to int if left & right are char this will facilitate hardware multiplies 8bit x 8bit = 16bit */ if (IS_CHAR(LETYPE(tree)) && IS_CHAR(RETYPE(tree))) { - TETYPE (tree) = getSpec (TTYPE (tree) = - computeType (LTYPE (tree), - RTYPE (tree))); SPEC_NOUN(TETYPE(tree)) = V_INT; - } else { - TETYPE (tree) = getSpec (TTYPE (tree) = - computeType (LTYPE (tree), - RTYPE (tree))); } return tree;