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

This commit is contained in:
Wolfgang Bumiller 2012-12-31 12:29:25 +01:00
parent 26d43e650f
commit d47da25b82
6 changed files with 22 additions and 39 deletions

View 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.

View file

@ -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

1
main.c
View file

@ -163,6 +163,7 @@ static bool options_parse(int argc, char **argv) {
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")) {

2
opts.c
View file

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

View file

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

View file

@ -1403,37 +1403,20 @@ 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;
}
else
{
if (fval)
return !parsewarning(parser, WARN_TOO_FEW_PARAMETERS,
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
return !parsewarning(parser, WARN_TOO_FEW_PARAMETERS,
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);
}
}
}
return true;
}