History

tccgen.c: Remove undefined shift of negative signed value.

Edmund Grimley Evans committed 11 years ago

Commit c8996591 parent eafd7a71 file · +4 −3Browse files

Unified · Split

tccgen.c+4−3
@@ -742,7 +742,7 @@ ST_FUNC int gv(int rc) · 741 unmodified lines
742742 bit_pos = (vtop->type.t >> VT_STRUCT_SHIFT) & 0x3f;
743743 bit_size = (vtop->type.t >> (VT_STRUCT_SHIFT + 6)) & 0x3f;
744744 /* remove bit field info to avoid loops */
745− vtop->type.t &= ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT));
745+ vtop->type.t &= ~VT_BITFIELD & ((1 << VT_STRUCT_SHIFT) - 1);
746746 /* cast to int to propagate signedness in following ops */
747747 if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
748748 type.t = VT_LLONG;
@@ -2545,7 +2545,8 @@ ST_FUNC void vstore(void) · 1796 unmodified lines
25452545 && !(vtop->type.t & VT_BITFIELD)) {
25462546 /* optimize char/short casts */
25472547 delayed_cast = VT_MUSTCAST;
2548− vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT)));
2548+ vtop->type.t = (ft & VT_TYPE & ~VT_BITFIELD &
2549+ ((1 << VT_STRUCT_SHIFT) - 1));
25492550 /* XXX: factorize */
25502551 if (ft & VT_CONSTANT)
25512552 tcc_warning("assignment of read-only location");
@@ -2599,7 +2600,7 @@ ST_FUNC void vstore(void) · 47 unmodified lines
25992600 bit_pos = (ft >> VT_STRUCT_SHIFT) & 0x3f;
26002601 bit_size = (ft >> (VT_STRUCT_SHIFT + 6)) & 0x3f;
26012602 /* remove bit field info to avoid loops */
2602− vtop[-1].type.t = ft & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT));
2603+ vtop[-1].type.t = ft & ~VT_BITFIELD & ((1 << VT_STRUCT_SHIFT) - 1);
26032604
26042605 if((ft & VT_BTYPE) == VT_BOOL) {
26052606 gen_cast(&vtop[-1].type);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t