diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-05-31 17:19:10 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-22 23:07:01 +0200 |
| commit | 0b73dee0171a15800d0a4ae6225b602bf8961599 (patch) | |
| tree | 5774c0b92ff1041c893fa770f5492c4ef8b1160f | |
| parent | 411aed021d36aa07fa49d8393776c9a512346871 (diff) | |
| download | sparse-dev-0b73dee0171a15800d0a4ae6225b602bf8961599.tar.gz | |
big-shift: move the check into check_shift_count()
At expansion time, diagnostic about the size of shifts is issued
by an helper check_shift_count() and the condition are checked
before calling this functions.
Move the condition checking inside the helper as it make the
code more readable (and this corresponds to the helper's name).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | expand.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -160,6 +160,8 @@ Float: static void check_shift_count(struct expression *expr, struct symbol *ctype, unsigned int count) { + if (count < ctype->bit_size) + return; warning(expr->pos, "shift too big (%u) for type %s", count, show_typename(ctype)); } @@ -181,11 +183,9 @@ static int simplify_int_binop(struct expression *expr, struct symbol *ctype) return 0; r = right->value; if (expr->op == SPECIAL_LEFTSHIFT || expr->op == SPECIAL_RIGHTSHIFT) { - if (r >= ctype->bit_size) { - if (conservative) - return 0; - check_shift_count(expr, ctype, r); - } + if (conservative) + return 0; + check_shift_count(expr, ctype, r); } if (left->type != EXPR_VALUE) return 0; |
