Unified · Split
| @@ -286,6 +286,8 @@ struct TCCState { · 285 unmodified lines | ||
| 286 | 286 | char/short stored in integer registers) */ |
| 287 | 287 | #define VT_MUSTBOUND 0x0800 /* bound checking must be done before |
| 288 | 288 | dereferencing value */ |
| 289 | +#define VT_BOUNDED 0x8000 /* value is bounded. The address of the | |
| 290 | + bounding function call point is in vc */ | |
| 289 | 291 | #define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */ |
| 290 | 292 | #define VT_LVAL_SHORT 0x2000 /* lvalue is a short */ |
| 291 | 293 | #define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */ |
| @@ -2660,12 +2662,16 @@ void gbound(void) · 2368 unmodified lines | ||
| 2660 | 2662 | vtop->r &= ~VT_MUSTBOUND; |
| 2661 | 2663 | /* if lvalue, then use checking code before dereferencing */ |
| 2662 | 2664 | if (vtop->r & VT_LVAL) { |
| 2663 | − lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL); | |
| 2664 | − gaddrof(); | |
| 2665 | − vpushi(0); | |
| 2666 | − gen_bounded_ptr_add1(); | |
| 2667 | − gen_bounded_ptr_add2(1); | |
| 2668 | − vtop->r |= lval_type; | |
| 2665 | + /* if not VT_BOUNDED value, then make one */ | |
| 2666 | + if (!(vtop->r & VT_BOUNDED)) { | |
| 2667 | + lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL); | |
| 2668 | + gaddrof(); | |
| 2669 | + vpushi(0); | |
| 2670 | + gen_bounded_ptr_add(); | |
| 2671 | + vtop->r |= lval_type; | |
| 2672 | + } | |
| 2673 | + /* then check for dereferencing */ | |
| 2674 | + gen_bounded_ptr_deref(); | |
| 2669 | 2675 | } |
| 2670 | 2676 | } |
| 2671 | 2677 | #endif |
| @@ -3365,9 +3371,8 @@ void gen_op(int op) · 693 unmodified lines | ||
| 3365 | 3371 | vswap(); |
| 3366 | 3372 | gen_op('-'); |
| 3367 | 3373 | } |
| 3368 | − gen_bounded_ptr_add1(); | |
| 3369 | − gen_bounded_ptr_add2(0); | |
| 3370 | − } else | |
| 3374 | + gen_bounded_ptr_add(); | |
| 3375 | + } else | |
| 3371 | 3376 | #endif |
| 3372 | 3377 | { |
| 3373 | 3378 | gen_opic(op); |