From 3bc32d46494c404df7905fceaca9156830ff97f1 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sat, 8 Aug 2020 02:19:39 +0200 Subject: fix checking if type is void Sparse warns if a void function returns a non-void expression. But the check directly compares the returned type with void_ctype, without taking in account the presence of a SYM_NODE. In consequence, sparse issues a few false warnings. Fix this by using is_void_type() to test the returned type. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evaluate.c b/evaluate.c index dddea761..6d5bbca5 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3544,7 +3544,7 @@ static struct symbol *evaluate_return_expression(struct statement *stmt) fntype = current_fn->ctype.base_type; rettype = fntype->ctype.base_type; if (!rettype || rettype == &void_ctype) { - if (expr && expr->ctype != &void_ctype) + if (expr && !is_void_type(expr->ctype)) expression_error(expr, "return expression in %s function", rettype?"void":"typeless"); if (expr && Wreturn_void) warning(stmt->pos, "returning void-valued expression"); -- cgit 1.2.3-korg