aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-09 16:34:21 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-13 21:27:15 +0200
commit14e84ffc0e76784ddfb7bfcea61bc3e2bac00cc0 (patch)
tree8ca59f00a1268f071cac275441f9fab0626b17b4 /evaluate.c
parentc122e6540d537f2aa957631435a25d04ed58fef6 (diff)
downloadsparse-dev-14e84ffc0e76784ddfb7bfcea61bc3e2bac00cc0.tar.gz
fix evaluation error with assignment of qualified arrays
This is a fix for a problem reported today to the mailing list. In check_assignment_types(), the first 'level' is checked by the function itself but the next level is checked by the type_difference(). This later function take as arguments, beside the types to be checked, the modifiers that can be assumed for each of the types (this works as a kind of reverse mask). But these modifiers are taken from target_qualifiers() which, purposely ignore the modifiers for arrays introduced in commit 984b7b66457c ("[PATCH] deal correctly with qualifiers on arrays") with the comment: "Pointers to any array are considered as pointers to unqualified type as far as implicit conversions are concerned" But by dropping these modifiers, type_difference() reports incorrect results for pointers to qualified arrays. So, do not use target_qualifiers() but take the modifiers directly from the ctypes. Admittingly, I'm far from sure that this is the right fix but it solve several wrong cases. 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 f515ce6f..dddea761 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1444,8 +1444,8 @@ static int check_assignment_types(struct symbol *target, struct expression **rp,
}
b1 = examine_pointer_target(t);
b2 = examine_pointer_target(s);
- mod1 = target_qualifiers(t);
- mod2 = target_qualifiers(s);
+ mod1 = t->ctype.modifiers & MOD_IGN;
+ mod2 = s->ctype.modifiers & MOD_IGN;
if (whitelist_pointers(b1, b2)) {
/*
* assignments to/from void * are OK, provided that