From: kvigor Date: Wed, 24 Jan 2001 22:10:09 +0000 (+0000) Subject: promote operands to shift operations to int X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=136d4a3df55869c9ce2698e6bec4a43340a088f3;p=fw%2Fsdcc promote operands to shift operations to int git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@532 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCicode.c b/src/SDCCicode.c index ecbb2b8d..00f1ee2f 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2116,10 +2116,20 @@ operand *geniCodeUnaryMinus (operand *op) operand *geniCodeLeftShift (operand *left, operand *right) { iCode *ic; - sym_link *ltype = operandType(left); + + /* Operands must be promoted to int, according to ISO. */ + if (getSize(operandType(right)) < INTSIZE) + { + right = geniCodeCast(INTTYPE,right,TRUE); + } + + if (getSize(operandType(left)) < INTSIZE) + { + left = geniCodeCast(INTTYPE,left,TRUE); + } ic = newiCode(LEFT_OP,left,right); - IC_RESULT(ic) = newiTempOperand(ltype,0); + IC_RESULT(ic) = newiTempOperand(operandType(left),0); ADDTOCHAIN(ic); return IC_RESULT(ic) ; } @@ -2130,10 +2140,20 @@ operand *geniCodeLeftShift (operand *left, operand *right) operand *geniCodeRightShift (operand *left, operand *right) { iCode *ic; - sym_link *ltype = operandType(left); + + /* Operands must be promoted to int, according to ISO. */ + if (getSize(operandType(right)) < INTSIZE) + { + right = geniCodeCast(INTTYPE,right,TRUE); + } + + if (getSize(operandType(left)) < INTSIZE) + { + left = geniCodeCast(INTTYPE,left,TRUE); + } ic = newiCode(RIGHT_OP,left,right); - IC_RESULT(ic) = newiTempOperand(ltype,0); + IC_RESULT(ic) = newiTempOperand(operandType(left),0); ADDTOCHAIN(ic); return IC_RESULT(ic) ; }