From: Wolfgang Bumiller Date: Mon, 31 Dec 2012 11:29:25 +0000 (+0100) Subject: Changing -Wtoo-few-parameters to -Winvalid-parameter-count; removing hardcoded COMPIL... X-Git-Tag: before-library~411 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=d47da25b826f97908876bb8adc01726c6a689966 Changing -Wtoo-few-parameters to -Winvalid-parameter-count; removing hardcoded COMPILER_GMQCC code which makes invalid parameter counts an error and instead make -std=gmqcc imply -Werror-invalid-parameter-count --- diff --git a/doc/gmqcc.1 b/doc/gmqcc.1 index a2a3604..ecdac55 100644 --- a/doc/gmqcc.1 +++ b/doc/gmqcc.1 @@ -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. diff --git a/gmqcc.ini.example b/gmqcc.ini.example index d171e95..2c63fcd 100644 --- a/gmqcc.ini.example +++ b/gmqcc.ini.example @@ -125,7 +125,7 @@ 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 1946795..8abb193 100644 --- 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 ec8e40b..d326e42 100644 --- 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); diff --git a/opts.def b/opts.def index 9ed9de8..a1576da 100644 --- 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) diff --git a/parser.c b/parser.c index 56b060b..26a8685 100644 --- 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); } }