aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorVincent Lefevre <vincent@vinc17.net>2012-07-06 14:22:37 +0200
committerVincent Lefevre <vincent@vinc17.net>2012-07-06 14:22:37 +0200
commitd27a0b35482b907357d76a9db4e0b18ec89cf979 (patch)
treeeb46f29168e1d4d977a33ac35ea1a01f087cc9f6 /tccgen.c
parent09b98a42a38b3c0bd6eb9de99dc8a4fc3951a760 (diff)
downloadtinycc-d27a0b35482b907357d76a9db4e0b18ec89cf979.tar.gz
tinycc-d27a0b35482b907357d76a9db4e0b18ec89cf979.tar.bz2
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.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tccgen.c b/tccgen.c
index 26a5781..d27bdba 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -1679,7 +1679,9 @@ ST_FUNC void gen_op(int op)
tcc_error("invalid operands for binary operation");
goto std_op;
} 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;
} else if (bt1 == VT_LLONG || bt2 == VT_LLONG) {
/* cast to biggest op */