fixed bug #514865
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 22 Feb 2002 11:44:44 +0000 (11:44 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 22 Feb 2002 11:44:44 +0000 (11:44 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1948 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c

index ff46ece9a0a5353603a08d744c21ba40bdcad498..ea0a777a498fc085e726dcb19d2f26c62581b92a 100644 (file)
@@ -2655,6 +2655,15 @@ decorateType (ast * tree)
                                   tree->opval.val->type);
          return tree;
        }
+      /* a left shift must be done with at least 16bits */
+      if ((tree->opval.op==LEFT_OP) && (getSize(LTYPE(tree))<2)) {
+       // insert a cast
+       tree->left = 
+         decorateType (newNode (CAST,
+                                newAst_LINK(copyLinkChain(LTYPE(tree))),
+                                tree->left));
+       SPEC_NOUN(tree->left->left->ftype)=V_INT;
+      }
       /* if only the right side is a literal & we are
          shifting more than size of the left operand then zero */
       if (IS_LITERAL (RTYPE (tree)) &&