aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-01-21 06:47:07 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-01-31 17:54:23 +0100
commitb61bfb16326e034ec12c31491bf3897cce9f3e4d (patch)
treef04ca6383ea847514679734e693d42e449fcb0e8 /evaluate.c
parent1829a899f5062fc010a4603533f944a08a1aba1d (diff)
downloadsparse-b61bfb16326e034ec12c31491bf3897cce9f3e4d.tar.gz
report type & size on non-power-of-2 pointer subtraction
The option -Wptr-subtraction-blows warns when pointer subtraction is done and the base size is not a power-of-2. However, the current message doesn't give much context. Change this by giving the base type and the size in the warning. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/evaluate.c b/evaluate.c
index 4be4e8e5..402fa04a 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -847,8 +847,10 @@ static struct symbol *evaluate_ptr_sub(struct expression *expr)
val->value = value;
if (value & (value-1)) {
- if (Wptr_subtraction_blows)
+ if (Wptr_subtraction_blows) {
warning(expr->pos, "potentially expensive pointer subtraction");
+ info(expr->pos, " '%s' has a non-power-of-2 size: %lu", show_typename(lbase), value);
+ }
}
sub->op = '-';