aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-08-23 16:11:27 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-08-23 16:11:27 -0700
commit658ee8e0f63121c5029d91b4d5df169c6ddfcbb8 (patch)
tree02b4d677062252ce1f8c3ff21f9669042cc1f94d
parent18f17cde1e9835bb301e4ca64e0898166b155c90 (diff)
downloadsparse-658ee8e0f63121c5029d91b4d5df169c6ddfcbb8.tar.gz
unrestricted values are unrestricted even after a cast
This isn't as tight as it should be, but it basically treats the special unrestricted constants (zero and all ones) as unrestricted values even after they have been explicitly cast to teh restricted type. And yes, this should actually check that type matches too, but I think all the cases that care will warn about the types not matching separately anyway. This is the quick hack. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--evaluate.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/evaluate.c b/evaluate.c
index f49a0614..6a3f798d 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -416,6 +416,8 @@ static struct symbol *bad_expr_type(struct expression *expr)
static int restricted_value(struct expression *v, struct symbol *type)
{
+ if (v->type == EXPR_CAST)
+ v = v->cast_expression;
if (v->type != EXPR_VALUE)
return 1;
if (v->value != 0) {