diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-08 02:19:39 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-09 01:42:12 +0200 |
commit | 3bc32d46494c404df7905fceaca9156830ff97f1 (patch) | |
tree | 2149c37defb85b4f3891c6f54898f5a192c55686 | |
parent | e1578773182e8f69c3a0cd8add8dfbe7561a8240 (diff) | |
download | sparse-3bc32d46494c404df7905fceaca9156830ff97f1.tar.gz |
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 <luc.vanoostenryck@gmail.com>
-rw-r--r-- | evaluate.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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"); |