]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
set -Wmissing-return-values to on by default, new warning: control reaches end of...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 19 Aug 2012 18:26:54 +0000 (20:26 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 19 Aug 2012 18:26:54 +0000 (20:26 +0200)
main.c
parser.c

diff --git a/main.c b/main.c
index 68c5fa7fa3385d5ed520dbaa41ba86c943292e5b..d629373511ced9d31d2e1a29614c1e1a8c7094ae 100644 (file)
--- 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();
index 5143b856ed0ba304097a889964054bd65809c9de..e608223925eee933c3650ca8e77e82c7a87fcf7a 100644 (file)
--- 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);
     }