Incorrect shift result type on unsigned short first argument.

The code for shifts is now similar to code for binary arithmetic operations,
except that only the first argument is considered, as required by the ISO C
standard.
This commit is contained in:
Vincent Lefevre 2012-07-06 14:22:37 +02:00
parent 09b98a42a3
commit d27a0b3548

View File

@ -1679,7 +1679,9 @@ ST_FUNC void gen_op(int op)
tcc_error("invalid operands for binary operation"); tcc_error("invalid operands for binary operation");
goto std_op; goto std_op;
} else if (op == TOK_SHR || op == TOK_SAR || op == TOK_SHL) { } else if (op == TOK_SHR || op == TOK_SAR || op == TOK_SHL) {
t = (bt1 == VT_LLONG ? VT_LLONG : VT_INT) | (t1 & VT_UNSIGNED); t = bt1 == VT_LLONG ? VT_LLONG : VT_INT;
if ((t1 & (VT_BTYPE | VT_UNSIGNED)) == (t | VT_UNSIGNED))
t |= VT_UNSIGNED;
goto std_op; goto std_op;
} else if (bt1 == VT_LLONG || bt2 == VT_LLONG) { } else if (bt1 == VT_LLONG || bt2 == VT_LLONG) {
/* cast to biggest op */ /* cast to biggest op */