Fix type checking of variadic functions
PATCH 1/1 Fix type checking of variadic functions
When doing a type comparison between functions, in the varidicity part, the base type of these functions (= their return type) is wrongly used intead of their own type.
Fix this and add some tests showing this and others cases are now OK
--- evaluate.c | 2 +- validation/function-redecl.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 validation/function-redecl.c
evaluate.c +1 -1
@@ -729,7 +729,7 @@ const char *type_difference(struct ctype *c1, struct ctype *c2, mod2 = t2->ctype.modifiers; as2 = t2->ctype.as; -if (base1->variadic != base2->variadic) +if (t1->variadic != t2->variadic)return "incompatible variadic arguments" ;examine_fn_arguments (t1);examine_fn_arguments (t2);
validation/function-redecl.c new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.10.1
Christopher Li
maintainerQuoted 6 lines · Luc Van Oostenryck
When doing a type comparison between functions, in the varidicity part, the base type of these functions (= their return type) is wrongly used intead of their own type.
Fix this and add some tests showing this and others cases are now OK
This looks correct to me. The function return type can't be a function. So the base type of the functions will never have the variadic bit set.
Speaking of the test case, there are two case can be added:
void arg_incomplete();
void arg_incomplete(int a) {} /* check-should-pass */
void arg_incomplete_vararg();
void arg_incomplete_vararg(int a, ...) {} /* check-should-fail */
Sparse handle the first one incorrectly. But that is a separate issue, we can address it in a different patch.
Will apply.
Chris
Quoted 8 lines · Christopher Li
Speaking of the test case, there are two case can be added:
void
arg_incomplete();
voidarg_incomplete(int a){} /* check-should-pass */void
arg_incomplete_vararg();
voidarg_incomplete_vararg(int a, ...){} /* check-should-fail */
Quoted 7 lines
Sparse handle the first one incorrectly. But that is a separate issue, we can address it in a different patch.
Will apply.
Chris
--
Yes. I'll look at this later.
Luc