* [PATCH 4/8] start cleaning type_difference()
@ 2007-07-13 17:44 Al Viro
0 siblings, 0 replies; only message in thread
From: Al Viro @ 2007-07-13 17:44 UTC (permalink / raw)
To: linux-sparse
a) examine_fn_arguments() when comparing SYM_FN nodes; then
we won't need to try implementing argument adjustment as
part of the main loop. SYM_ARRAY->SYM_PTR and SYM_FN/SYM_PTR
interactions go away (and we stop getting nonsense results
like "int * and int [1] are the same thing"). All callers
are already happy with that.
b) different structs or unions are incompatible.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
evaluate.c | 34 +++++++++-------------------------
1 files changed, 9 insertions(+), 25 deletions(-)
diff --git a/evaluate.c b/evaluate.c
index 88435da..91c7f74 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -619,6 +619,8 @@ static struct symbol *evaluate_ptr_add(struct expression *expr, struct symbol *c
return ctype;
}
+static void examine_fn_arguments(struct symbol *fn);
+
const char * type_difference(struct symbol *target, struct symbol *source,
unsigned long target_mod_ignore, unsigned long source_mod_ignore)
{
@@ -687,34 +689,14 @@ const char * type_difference(struct symbol *target, struct symbol *source,
/*
* Pointers to functions compare as the function itself
*/
- if (type1 == SYM_PTR && base1) {
+ if (type1 == SYM_PTR && base1)
base1 = examine_symbol_type(base1);
- switch (base1->type) {
- case SYM_FN:
- type1 = SYM_FN;
- target = base1;
- base1 = base1->ctype.base_type;
- default:
- /* nothing */;
- }
- }
- if (type2 == SYM_PTR && base2) {
- base2 = examine_symbol_type(base2);
- switch (base2->type) {
- case SYM_FN:
- type2 = SYM_FN;
- source = base2;
- base2 = base2->ctype.base_type;
- default:
- /* nothing */;
- }
- }
- /* Arrays degenerate to pointers for type comparisons */
- type1 = (type1 == SYM_ARRAY) ? SYM_PTR : type1;
- type2 = (type2 == SYM_ARRAY) ? SYM_PTR : type2;
+ if (type2 == SYM_PTR && base2)
+ base2 = examine_symbol_type(base2);
- if (type1 != type2 || type1 == SYM_RESTRICT)
+ if (type1 != type2 || type1 == SYM_RESTRICT ||
+ type1 == SYM_UNION || type1 == SYM_STRUCT)
return "different base types";
/* Must be same address space to be comparable */
@@ -755,6 +737,8 @@ const char * type_difference(struct symbol *target, struct symbol *source,
struct symbol *arg1, *arg2;
if (base1->variadic != base2->variadic)
return "incompatible variadic arguments";
+ examine_fn_arguments(target);
+ examine_fn_arguments(source);
PREPARE_PTR_LIST(target->arguments, arg1);
PREPARE_PTR_LIST(source->arguments, arg2);
i = 1;
--
1.5.0-rc2.GIT
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-07-13 17:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-13 17:44 [PATCH 4/8] start cleaning type_difference() Al Viro
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).