conditional on -Wreturn-void Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx> --- evaluate.c | 2 ++ lib.c | 2 ++ lib.h | 1 + 3 files changed, 5 insertions(+), 0 deletions(-) diff --git a/evaluate.c b/evaluate.c index e3b4940..07ebf0c 100644 --- a/evaluate.c +++ b/evaluate.c @@ -2790,6 +2790,8 @@ static struct symbol *evaluate_return_expression(struct statement *stmt) if (!fntype || fntype == &void_ctype) { if (expr && expr->ctype != &void_ctype) expression_error(expr, "return expression in %s function", fntype?"void":"typeless"); + if (expr && Wreturn_void) + warning(stmt->pos, "returning void-valued expression"); return NULL; } diff --git a/lib.c b/lib.c index 4856b65..7f6334c 100644 --- a/lib.c +++ b/lib.c @@ -207,6 +207,7 @@ int Wuninitialized = 1; int Wold_initializer = 1; int Wnon_pointer_null = 1; int Wparen_string = 0; +int Wreturn_void = 0; int dbg_entry = 0; int dbg_dead = 0; @@ -359,6 +360,7 @@ static const struct warning { { "old-initializer", &Wold_initializer }, { "non-pointer-null", &Wnon_pointer_null }, { "paren-string", &Wparen_string }, + { "return-void", &Wreturn_void }, }; enum { diff --git a/lib.h b/lib.h index 0fe4d2a..bc2a8c2 100644 --- a/lib.h +++ b/lib.h @@ -104,6 +104,7 @@ extern int Wuninitialized; extern int Wold_initializer; extern int Wnon_pointer_null; extern int Wparen_string; +extern int Wreturn_void; extern int dbg_entry; extern int dbg_dead; -- 1.5.0-rc2.GIT - 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