Changing -Wtoo-few-parameters to -Winvalid-parameter-count; removing hardcoded COMPIL...
authorWolfgang Bumiller <blub@speed.at>
Mon, 31 Dec 2012 11:29:25 +0000 (12:29 +0100)
committerWolfgang Bumiller <blub@speed.at>
Mon, 31 Dec 2012 11:29:25 +0000 (12:29 +0100)
doc/gmqcc.1
gmqcc.ini.example
main.c
opts.c
opts.def
parser.c

index a2a36041cc62fa6bccacacb7af5ba9e7fdc3066c..ecdac55762b23f29b7b69743add5cf27871cae66 100644 (file)
@@ -165,9 +165,8 @@ optionally enable a warning.
 Functions which aren't of type \fIvoid\fR will warn if it possible to
 reach the end without returning an actual value.
 .TP
-.B -Wtoo-few-parameters
-Warn about a function call with fewer parameters than the function
-expects.
+.B -Winvalid-parameter-count
+Warn about a function call with an invalid number of parameters.
 .TP
 .B -Wlocal-shadows
 Warn when a locally declared variable shadows variable.
index d171e959e8c001cefed6410f0a486f591b24ca53..2c63fcd44e0a1f14205e52b9703aec6331a86834 100644 (file)
     MISSING_RETURN_VALUES        = true
 
     # Enables warnings about missing parameters for function calls.
-    TOO_FEW_PARAMETERS           = true
+    INVALID_PARAMETER_COUNT      = true
 
     # Enables warnings about locals shadowing parameters or other locals.
     LOCAL_SHADOWS                = true
diff --git a/main.c b/main.c
index 194679582a8ab4592417677c31c07b329f59d7e0..8abb1937edf3bcfa42e579da53426dd4df014975 100644 (file)
--- a/main.c
+++ b/main.c
@@ -158,11 +158,12 @@ static bool options_parse(int argc, char **argv) {
             if (options_long_gcc("std", &argc, &argv, &argarg)) {
                 if (!strcmp(argarg, "gmqcc") || !strcmp(argarg, "default")) {
 
-                    opts_set(opts.flags, ADJUST_VECTOR_FIELDS, true);
-                    opts_set(opts.flags, CORRECT_LOGIC,        true);
-                    opts_set(opts.flags, FALSE_EMPTY_STRINGS,  false);
-                    opts_set(opts.flags, TRUE_EMPTY_STRINGS,   true);
-                    opts_set(opts.flags, LOOP_LABELS,          true);
+                    opts_set(opts.flags, ADJUST_VECTOR_FIELDS,          true);
+                    opts_set(opts.flags, CORRECT_LOGIC,                 true);
+                    opts_set(opts.flags, FALSE_EMPTY_STRINGS,           false);
+                    opts_set(opts.flags, TRUE_EMPTY_STRINGS,            true);
+                    opts_set(opts.flags, LOOP_LABELS,                   true);
+                    opts_set(opts.werror, WARN_INVALID_PARAMETER_COUNT, true);
                     opts.standard = COMPILER_GMQCC;
 
                 } else if (!strcmp(argarg, "qcc")) {
diff --git a/opts.c b/opts.c
index ec8e40b6552da7c7567eea32dd34ce1450e8b596..d326e42906647b9f3e9775fd254586dccd197e3a 100644 (file)
--- a/opts.c
+++ b/opts.c
@@ -35,7 +35,7 @@ static void opts_setdefault() {
     opts_set(opts.warn,  WARN_EXTENSIONS,                true);
     opts_set(opts.warn,  WARN_FIELD_REDECLARED,          true);
     opts_set(opts.warn,  WARN_MISSING_RETURN_VALUES,     true);
-    opts_set(opts.warn,  WARN_TOO_FEW_PARAMETERS,        true);
+    opts_set(opts.warn,  WARN_INVALID_PARAMETER_COUNT,   true);
     opts_set(opts.warn,  WARN_LOCAL_SHADOWS,             false);
     opts_set(opts.warn,  WARN_LOCAL_CONSTANTS,           true);
     opts_set(opts.warn,  WARN_VOID_VARIABLES,            true);
index 9ed9de83d8565cbaaf670e902f95fe3dad50dfe9..a1576daaf9f5b7b0c0a3a16a3bc7fa87bc212caa 100644 (file)
--- a/opts.def
+++ b/opts.def
@@ -59,7 +59,7 @@
     GMQCC_DEFINE_FLAG(EXTENSIONS)
     GMQCC_DEFINE_FLAG(FIELD_REDECLARED)
     GMQCC_DEFINE_FLAG(MISSING_RETURN_VALUES)
-    GMQCC_DEFINE_FLAG(TOO_FEW_PARAMETERS)
+    GMQCC_DEFINE_FLAG(INVALID_PARAMETER_COUNT)
     GMQCC_DEFINE_FLAG(LOCAL_SHADOWS)
     GMQCC_DEFINE_FLAG(LOCAL_CONSTANTS)
     GMQCC_DEFINE_FLAG(VOID_VARIABLES)
index 56b060b14d3a8c772905174e897e3445e7db0e4e..26a86858ba8f620d0620feaefcac830f45a056ca 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1403,35 +1403,18 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
               vec_size(fun->expression.params) < paramcount))
         {
             const char *fewmany = (vec_size(fun->expression.params) > paramcount) ? "few" : "many";
-            if (opts.standard == COMPILER_GMQCC)
-            {
-                if (fval)
-                    parseerror(parser, "too %s parameters for call to %s: expected %i, got %i\n"
-                               " -> `%s` has been declared here: %s:%i",
-                               fewmany, fval->name, (int)vec_size(fun->expression.params), (int)paramcount,
-                               fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line);
-                else
-                    parseerror(parser, "too %s parameters for function call: expected %i, got %i\n"
-                               " -> it has been declared here: %s:%i",
-                               fewmany, (int)vec_size(fun->expression.params), (int)paramcount,
-                               ast_ctx(fun).file, (int)ast_ctx(fun).line);
-                return false;
-            }
+            if (fval)
+                return !parsewarning(parser, WARN_INVALID_PARAMETER_COUNT,
+                                     "too %s parameters for call to %s: expected %i, got %i\n"
+                                     " -> `%s` has been declared here: %s:%i",
+                                     fewmany, fval->name, (int)vec_size(fun->expression.params), (int)paramcount,
+                                     fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line);
             else
-            {
-                if (fval)
-                    return !parsewarning(parser, WARN_TOO_FEW_PARAMETERS,
-                                         "too %s parameters for call to %s: expected %i, got %i\n"
-                                         " -> `%s` has been declared here: %s:%i",
-                                         fewmany, fval->name, (int)vec_size(fun->expression.params), (int)paramcount,
-                                         fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line);
-                else
-                    return !parsewarning(parser, WARN_TOO_FEW_PARAMETERS,
-                                         "too %s parameters for function call: expected %i, got %i\n"
-                                         " -> it has been declared here: %s:%i",
-                                         fewmany, (int)vec_size(fun->expression.params), (int)paramcount,
-                                         ast_ctx(fun).file, (int)ast_ctx(fun).line);
-            }
+                return !parsewarning(parser, WARN_INVALID_PARAMETER_COUNT,
+                                     "too %s parameters for function call: expected %i, got %i\n"
+                                     " -> it has been declared here: %s:%i",
+                                     fewmany, (int)vec_size(fun->expression.params), (int)paramcount,
+                                     ast_ctx(fun).file, (int)ast_ctx(fun).line);
         }
     }