From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Subject: [PATCH 6/8] fix the sanity check in evaluate_ptr_sub()
Date: Fri, 13 Jul 2007 18:45:17 +0100 [thread overview]
Message-ID: <E1I9PCf-0000F5-5e@ZenIV.linux.org.uk> (raw)
We are checking the wrong thing - the arguments have already
degenerated, so we won't see SYM_FN there (or SYM_ARRAY, for
that matter). That check should be done to the target of
pointer, not to the pointer itself and it should simply check
for SYM_FN - that's what we'll get there both from decayed
functions _and_ pointers to functions.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
evaluate.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/evaluate.c b/evaluate.c
index 44a4da4..8df2042 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -785,24 +785,25 @@ static struct symbol *evaluate_ptr_sub(struct expression *expr)
struct symbol *ltype, *rtype;
struct expression *l = expr->left;
struct expression *r = expr->right;
+ struct symbol *lbase, *rbase;
- ltype = degenerate(l);
- rtype = degenerate(r);
+ classify_type(degenerate(l), <ype);
+ classify_type(degenerate(r), &rtype);
- ctype = ltype;
+ lbase = get_base_type(ltype);
+ rbase = get_base_type(rtype);
typediff = type_difference(ltype, rtype, ~MOD_SIZE, ~MOD_SIZE);
if (typediff)
expression_error(expr, "subtraction of different types can't work (%s)", typediff);
- examine_symbol_type(ctype);
+ ctype = lbase;
/* Figure out the base type we point to */
if (ctype->type == SYM_NODE)
ctype = ctype->ctype.base_type;
- if (ctype->type != SYM_PTR && ctype->type != SYM_ARRAY) {
+ if (ctype->type == SYM_FN) {
expression_error(expr, "subtraction of functions? Share your drugs");
return NULL;
}
- ctype = get_base_type(ctype);
expr->ctype = ssize_t_ctype;
if (ctype->bit_size > bits_in_char) {
--
1.5.0-rc2.GIT
reply other threads:[~2007-07-13 17:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1I9PCf-0000F5-5e@ZenIV.linux.org.uk \
--to=viro@ftp.linux.org.uk \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.