fixed bug#524708
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 2 Mar 2002 16:56:44 +0000 (16:56 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 2 Mar 2002 16:56:44 +0000 (16:56 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1975 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c

index b6f7cbfbd3a48a4511d631a1aba1463b46dcc1f4..871bf9045acce4bb9a01f77a11557a5a53f8214b 100644 (file)
@@ -2658,11 +2658,16 @@ decorateType (ast * 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 (IS_AST_SYM_VALUE(tree->left)) {
+         tree->left = 
+           decorateType (newNode (CAST,
+                                  newAst_LINK(copyLinkChain(LTYPE(tree))),
+                                  tree->left));
+         SPEC_NOUN(tree->left->left->ftype)=V_INT;
+       } else {
+         // must be a literal, we can do it right away
+         SPEC_NOUN(tree->left->opval.val->type)=V_INT;
+       }
       }
       /* if only the right side is a literal & we are
          shifting more than size of the left operand then zero */