* [PATCH 14/16] warn on return <void expression>;
@ 2007-06-24 8:05 Al Viro
0 siblings, 0 replies; only message in thread
From: Al Viro @ 2007-06-24 8:05 UTC (permalink / raw)
To: linux-sparse
conditional on -Wreturn-void
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-06-24 8:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-24 8:05 [PATCH 14/16] warn on return <void expression>; Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).