]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
-Wtoo-few-parameters on by deafult - for -std=gmqcc it's always an error
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 19:04:16 +0000 (21:04 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 19:04:16 +0000 (21:04 +0200)
main.c
parser.c
warns.def

diff --git a/main.c b/main.c
index 7369a9ca7d06987be0a7863becc8fe0583b42cb4..68c5fa7fa3385d5ed520dbaa41ba86c943292e5b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -381,6 +381,7 @@ int main(int argc, char **argv) {
     options_set(opts_warn, WARN_UNKNOWN_CONTROL_SEQUENCE, true);
     options_set(opts_warn, WARN_EXTENSIONS, true);
     options_set(opts_warn, WARN_FIELD_REDECLARED, true);
+    options_set(opts_warn, WARN_TOO_FEW_PARAMETERS, true);
 
     if (!options_parse(argc, argv)) {
         return usage();
index 1e8851734768a8c7934764742e1930abfbf91295..7af9664475233c8435379ef972a26caee2ad8c96 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -928,8 +928,29 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
         return false;
     } else {
         if (fun->expression.params_count != paramcount) {
-            parseerror(parser, "expected %i parameters, got %i", (int)fun->expression.params_count, paramcount);
-            return false;
+            ast_value *fval;
+            fval = (ast_istype(fun, ast_value) ? ((ast_value*)fun) : NULL);
+            if (opts_standard == COMPILER_GMQCC)
+            {
+                if (fval)
+                    parseerror(parser, "too few parameters for call to %s: expected %i, got %i",
+                               fval->name, (int)fun->expression.params_count, paramcount);
+                else
+                    parseerror(parser, "too few parameters for function call: expected %i, got %i",
+                               (int)fun->expression.params_count, paramcount);
+                return false;
+            }
+            else
+            {
+                if (fval)
+                    return parsewarning(parser, WARN_TOO_FEW_PARAMETERS,
+                                        "too few parameters for call to %s: expected %i, got %i",
+                                        fval->name, (int)fun->expression.params_count, paramcount);
+                else
+                    return parsewarning(parser, WARN_TOO_FEW_PARAMETERS,
+                                        "too few parameters for function call: expected %i, got %i",
+                                        (int)fun->expression.params_count, paramcount);
+            }
         }
     }
 
@@ -1617,7 +1638,7 @@ static bool parser_parse_statement(parser_t *parser, ast_block *block, ast_expre
                     parseerror(parser, "parse error");
                 if (expected->expression.next->expression.vtype != TYPE_VOID) {
                     if (opts_standard != COMPILER_GMQCC)
-                        parsewarning(parser, WARN_MISSING_RETURN_VALUES, "return without value");
+                        (void)!parsewarning(parser, WARN_MISSING_RETURN_VALUES, "return without value");
                     else
                         parseerror(parser, "return without value");
                 }
index 030e938d03e304c9588fe74222003002ebccb618..88b4cfccf9bf6925d21791d72f365f48fc62b80b 100644 (file)
--- a/warns.def
+++ b/warns.def
@@ -8,3 +8,4 @@ GMQCC_DEFINE_FLAG(UNKNOWN_CONTROL_SEQUENCE)
 GMQCC_DEFINE_FLAG(EXTENSIONS)
 GMQCC_DEFINE_FLAG(FIELD_REDECLARED)
 GMQCC_DEFINE_FLAG(MISSING_RETURN_VALUES)
+GMQCC_DEFINE_FLAG(TOO_FEW_PARAMETERS)