promote operands to shift operations to int
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 24 Jan 2001 22:10:09 +0000 (22:10 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 24 Jan 2001 22:10:09 +0000 (22:10 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@532 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCicode.c

index ecbb2b8da3f126b4b285b1472af7e1f5b58672de..00f1ee2fe81369066510ccb69646c71f921a6d75 100644 (file)
@@ -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) ;  
 }