diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2007-06-20 19:05:13 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2007-06-25 15:51:43 -0400 |
| commit | f78588abcebac0462764e5c8a3c91fa7a13bad45 (patch) | |
| tree | ad9a707cf2ac3e5ac730b33887361ff842f97919 | |
| parent | b0774891985015d7cdabacb3cc111e0291fd73f6 (diff) | |
| download | sparse-dev-f78588abcebac0462764e5c8a3c91fa7a13bad45.tar.gz | |
[PATCH] warn on return <void expression>;
conditional on -Wreturn-void
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | evaluate.c | 2 | ||||
| -rw-r--r-- | lib.c | 2 | ||||
| -rw-r--r-- | lib.h | 1 |
3 files changed, 5 insertions, 0 deletions
@@ -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; } @@ -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 { @@ -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; |
