Functions and arrays degenerate as pointers in most context but this wasn't done in the case of conditionals. As a result the value of the conditional after linearization was invalid. Fix this by calling degenerate() in evaluate_conditional(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- evaluate.c | 1 + validation/cond-address.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 validation/cond-address.c diff --git a/evaluate.c b/evaluate.c index f2d95c79d..976857915 100644 --- a/evaluate.c +++ b/evaluate.c @@ -881,6 +881,7 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator ctype = NULL; } } + ctype = degenerate(expr); return ctype; } diff --git a/validation/cond-address.c b/validation/cond-address.c new file mode 100644 index 000000000..2a69f4b92 --- /dev/null +++ b/validation/cond-address.c @@ -0,0 +1,14 @@ +extern void f(void); +extern int a[]; + +int foo(void) { if (f) return 1; return 0; } +int bar(void) { if (a) return 1; return 0; } +int qux(void) { if (f && a) return 1; return 0; } + +/* + * check-name: cond-address.c + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-excludes: VOID + */ -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html