set -Wmissing-return-values to on by default, new warning: control reaches end of non-void...

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-19 20:26:54 +02:00
parent 66ec592f94
commit 7ef248aadb
2 changed files with 9 additions and 0 deletions

1
main.c
View file

@ -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();

View file

@ -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);
}