From: Wolfgang (Blub) Bumiller Date: Sun, 19 Aug 2012 18:26:54 +0000 (+0200) Subject: set -Wmissing-return-values to on by default, new warning: control reaches end of... X-Git-Tag: 0.1-rc1~147 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7ef248aadb8de538c1075fb14f64a9722cbd238d;p=xonotic%2Fgmqcc.git set -Wmissing-return-values to on by default, new warning: control reaches end of non-void... --- 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); }