From: Al Viro <viro@ftp.linux.org.uk>
To: linux-sparse@vger.kernel.org
Subject: [PATCH 11/16] fix default argument promotion
Date: Sun, 24 Jun 2007 09:05:01 +0100 [thread overview]
Message-ID: <E1I2N5h-0003e0-7I@ZenIV.linux.org.uk> (raw)
It should do integer_promotion() for integer types, turn float into
double and degenerate() the functions/arrays. We do *not* want
compatible_assignment_type() in any case, though.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
evaluate.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/evaluate.c b/evaluate.c
index 6cb29ff..1d34cdf 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1897,15 +1897,24 @@ static int evaluate_arguments(struct symbol *f, struct symbol *fn, struct expres
if (!ctype)
return 0;
- ctype = degenerate(expr);
-
target = argtype;
- if (!target && ctype->bit_size < bits_in_int)
- target = &int_ctype;
- if (target) {
+ if (!target) {
+ struct symbol *type;
+ int class = classify_type(ctype, &type);
+ if (is_int(class)) {
+ *p = cast_to(expr, integer_promotion(type));
+ } else if (class & TYPE_FLOAT) {
+ unsigned long mod = type->ctype.modifiers;
+ if (!(mod & (MOD_LONG|MOD_LONGLONG)))
+ *p = cast_to(expr, &double_ctype);
+ } else if (class & TYPE_PTR) {
+ degenerate(expr);
+ }
+ } else {
static char where[30];
examine_symbol_type(target);
sprintf(where, "argument %d", i);
+ ctype = degenerate(expr);
compatible_assignment_types(expr, target, p, ctype, where);
}
--
1.5.0-rc2.GIT
reply other threads:[~2007-06-24 8:05 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=E1I2N5h-0003e0-7I@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).