aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-31 17:19:10 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-07-22 23:07:01 +0200
commit0b73dee0171a15800d0a4ae6225b602bf8961599 (patch)
tree5774c0b92ff1041c893fa770f5492c4ef8b1160f
parent411aed021d36aa07fa49d8393776c9a512346871 (diff)
downloadsparse-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.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/expand.c b/expand.c
index 484ead46..449dac05 100644
--- a/expand.c
+++ b/expand.c
@@ -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;