From 7ef248aadb8de538c1075fb14f64a9722cbd238d Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sun, 19 Aug 2012 20:26:54 +0200 Subject: [PATCH] set -Wmissing-return-values to on by default, new warning: control reaches end of non-void... --- main.c | 1 + parser.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/main.c b/main.c index 68c5fa7..d629373 100644 --- a/main.c +++ b/main.c @@ -382,6 +382,7 @@ int main(int argc, char **argv) { options_set(opts_warn, WARN_EXTENSIONS, true); options_set(opts_warn, WARN_FIELD_REDECLARED, true); options_set(opts_warn, WARN_TOO_FEW_PARAMETERS, true); + options_set(opts_warn, WARN_MISSING_RETURN_VALUES, true); if (!options_parse(argc, argv)) { return usage(); diff --git a/parser.c b/parser.c index 5143b85..e608223 100644 --- a/parser.c +++ b/parser.c @@ -1749,6 +1749,14 @@ static bool parser_parse_block_into(parser_t *parser, ast_block *block, bool war if (parser->tok != '}') { block = NULL; } else { + if (parser->function->vtype->expression.next->expression.vtype != TYPE_VOID) + { + if (!block->exprs_count || + !ast_istype(block->exprs[block->exprs_count-1], ast_return)) + { + parsewarning(parser, WARN_MISSING_RETURN_VALUES, "control reaches end of non-void function"); + } + } (void)parser_next(parser); } -- 2.39.2