X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCast.c;h=ea0a777a498fc085e726dcb19d2f26c62581b92a;hb=132d28cff95da487f685d09cad513f19060bc205;hp=ff46ece9a0a5353603a08d744c21ba40bdcad498;hpb=d57101349ebfacdbf4ef6ca799d16720c93e9453;p=fw%2Fsdcc diff --git a/src/SDCCast.c b/src/SDCCast.c index ff46ece9..ea0a777a 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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)) &&