aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-29 14:35:21 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-07-21 16:22:55 +0200
commit411aed021d36aa07fa49d8393776c9a512346871 (patch)
treef0d45492655b66df41c2f7a367b93c3dc799709f
parent9f739389cc8b23876bf46a5f25a38500a98eb1ef (diff)
downloadsparse-dev-411aed021d36aa07fa49d8393776c9a512346871.tar.gz
big-shift: don't take the modulo at expand time
Currently, at expansion time, shifts expressions with an amount corresponding to undefined behaviour (larger or equal than the type's width or negative) are 'reformed' by reducing the amount modulo the width. This correspond in fact to the run-time of several CPUs families (x86[-64], arm64, mips, ...) but not all of them (arm, ppc, ...). However, it is desirable for the front-end to not modify the exacution model, the virtual one given by the C standard, but also the effective one of the target machine. Change this, but no more doing the reduction modulo the width and leaving these expressions as-is (which leave the possibility to do something else, maybe target-specific, at a latter stage). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--expand.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/expand.c b/expand.c
index cd05ce11..484ead46 100644
--- a/expand.c
+++ b/expand.c
@@ -158,11 +158,9 @@ Float:
expr->type = EXPR_FVALUE;
}
-static int check_shift_count(struct expression *expr, struct symbol *ctype, unsigned int count)
+static void check_shift_count(struct expression *expr, struct symbol *ctype, unsigned int count)
{
warning(expr->pos, "shift too big (%u) for type %s", count, show_typename(ctype));
- count &= ctype->bit_size-1;
- return count;
}
/*
@@ -186,8 +184,7 @@ static int simplify_int_binop(struct expression *expr, struct symbol *ctype)
if (r >= ctype->bit_size) {
if (conservative)
return 0;
- r = check_shift_count(expr, ctype, r);
- right->value = r;
+ check_shift_count(expr, ctype, r);
}
}
if (left->type != EXPR_VALUE)