mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
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:
parent
26d43e650f
commit
d47da25b82
6 changed files with 22 additions and 39 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
11
main.c
11
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")) {
|
||||
|
|
2
opts.c
2
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);
|
||||
|
|
2
opts.def
2
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)
|
||||
|
|
39
parser.c
39
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue