aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-03-31 22:23:23 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-04-01 01:46:44 +0200
commit3f359ea14423d05b5096d414fbc01ca4cc3839df (patch)
tree033d96d84a71649a38221b3ecfbe3b3193b202b2 /evaluate.c
parentc4c9935b129f63fe837bab2e1e3e5db6d32b7fb8 (diff)
downloadsparse-dev-3f359ea14423d05b5096d414fbc01ca4cc3839df.tar.gz
fix allowing casts of AS pointers to uintptr_t
The patch b3daa62b5 ("also accept casts of AS pointers to uintptr_t") is bogus and allows uintptr_t as the *source type* instead of the *target type*. This was helped by a previous bug, in patch d96da358c ("stricter warning for explicit cast to ulong"), where a test for Wcast_from_as was wrongly added for the source type. Fix this by: * adding the test for uintptr_t to the target type; * removing the test for Wcast_from_as from the source type, replacing it by a test of Wcast_to_as; * clarify and extend the tge testcases. So, now, casts from uintptr_t to AS pointers are also allowed. Fixes: b3daa62b53109dba78c7937b3a6a0cd7d67865d5 Fixes: d96da358cfa0432f067a4e66940765883b80ee62 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/evaluate.c b/evaluate.c
index d9cd41d1..3268333a 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -3015,14 +3015,14 @@ static struct symbol *evaluate_cast(struct expression *expr)
}
}
- if (ttype == &ulong_ctype && !Wcast_from_as)
+ if ((ttype == &ulong_ctype || ttype == uintptr_ctype) && !Wcast_from_as)
tas = &bad_address_space;
else if (tclass == TYPE_PTR) {
examine_pointer_target(ttype);
tas = ttype->ctype.as;
}
- if ((stype == &ulong_ctype || stype == uintptr_ctype) && !Wcast_from_as)
+ if ((stype == &ulong_ctype || stype == uintptr_ctype))
sas = &bad_address_space;
else if (sclass == TYPE_PTR) {
examine_pointer_target(stype);