diff options
author | 2007-06-20 18:54:49 -0400 | |
---|---|---|
committer | 2007-06-25 15:50:57 -0400 | |
commit | 971a2af646b96dd79e42bd33ae9fb8a581fc539a (patch) | |
tree | 035e3fccb78fc433aeac4eb138ce346aaff6b4e4 /evaluate.c | |
parent | [PATCH] fix index conversions in evaluate_ptr_add() (diff) | |
download | sparse-971a2af646b96dd79e42bd33ae9fb8a581fc539a.tar.gz sparse-971a2af646b96dd79e42bd33ae9fb8a581fc539a.tar.bz2 sparse-971a2af646b96dd79e42bd33ae9fb8a581fc539a.zip |
[PATCH] fix default argument promotion
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>
Diffstat (limited to 'evaluate.c')
-rw-r--r-- | evaluate.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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); } |