fix for #1941, taken from 22d435b689
This commit is contained in:
@@ -169,27 +169,21 @@ void ShiftExpr (struct ExprDesc* Expr)
|
||||
}
|
||||
}
|
||||
|
||||
/* If the shift count is zero, nothing happens. If the left hand
|
||||
** side is a constant, the result is constant.
|
||||
*/
|
||||
if (Expr2.IVal == 0 || lconst) {
|
||||
|
||||
/* Set the type */
|
||||
/* If the left hand side is a constant, the result is constant */
|
||||
if (lconst) {
|
||||
/* Set the result type */
|
||||
Expr->Type = ResultType;
|
||||
|
||||
if (lconst) {
|
||||
|
||||
/* Evaluate the result */
|
||||
switch (Tok) {
|
||||
case TOK_SHL: Expr->IVal <<= Expr2.IVal; break;
|
||||
case TOK_SHR: Expr->IVal >>= Expr2.IVal; break;
|
||||
default: /* Shutup gcc */ break;
|
||||
}
|
||||
|
||||
/* Limit the calculated value to the range of its type */
|
||||
LimitExprValue (Expr, 1);
|
||||
/* Evaluate the result */
|
||||
switch (Tok) {
|
||||
case TOK_SHL: Expr->IVal <<= Expr2.IVal; break;
|
||||
case TOK_SHR: Expr->IVal >>= Expr2.IVal; break;
|
||||
default: /* Shutup gcc */ break;
|
||||
}
|
||||
|
||||
/* Limit the calculated value to the range of its type */
|
||||
LimitExprValue (Expr, 1);
|
||||
|
||||
/* Result is already got, remove the generated code */
|
||||
RemoveCode (&Mark1);
|
||||
|
||||
@@ -197,6 +191,15 @@ void ShiftExpr (struct ExprDesc* Expr)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the shift count is zero, nothing happens */
|
||||
if (Expr2.IVal == 0) {
|
||||
/* Result is already got, remove the pushing code */
|
||||
RemoveCode (&Mark2);
|
||||
|
||||
/* Be sure to mark the value as in the primary */
|
||||
goto MakeRVal;
|
||||
}
|
||||
|
||||
/* If we're shifting an integer or unsigned to the right, the lhs
|
||||
** has a quasi-const address, and the shift count is larger than 8,
|
||||
** we can load just the high byte as a char with the correct
|
||||
|
||||
Reference in New Issue
Block a user