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.
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
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")) {
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);
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)
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);
}
}