]> git.gag.com Git - fw/sdcc/commitdiff
fixed the implicit integral promotion as in
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 28 Dec 2002 13:16:48 +0000 (13:16 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 28 Dec 2002 13:16:48 +0000 (13:16 +0000)
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

src/SDCCast.c

index 63a7896651d62ebcd3bdaab85fb3d8270d8528d8..14c2f2d1694b43c8a3ae0ef3ff342a386819e3b6 100644 (file)
@@ -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;