From: Wolfgang (Blub) Bumiller Date: Sat, 18 Aug 2012 19:04:16 +0000 (+0200) Subject: -Wtoo-few-parameters on by deafult - for -std=gmqcc it's always an error X-Git-Tag: 0.1-rc1~180 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4d0be789ac7213aac7238b677413c02d0b753095;p=xonotic%2Fgmqcc.git -Wtoo-few-parameters on by deafult - for -std=gmqcc it's always an error --- diff --git a/main.c b/main.c index 7369a9c..68c5fa7 100644 --- a/main.c +++ b/main.c @@ -381,6 +381,7 @@ int main(int argc, char **argv) { options_set(opts_warn, WARN_UNKNOWN_CONTROL_SEQUENCE, true); options_set(opts_warn, WARN_EXTENSIONS, true); options_set(opts_warn, WARN_FIELD_REDECLARED, true); + options_set(opts_warn, WARN_TOO_FEW_PARAMETERS, true); if (!options_parse(argc, argv)) { return usage(); diff --git a/parser.c b/parser.c index 1e88517..7af9664 100644 --- a/parser.c +++ b/parser.c @@ -928,8 +928,29 @@ static bool parser_close_call(parser_t *parser, shunt *sy) return false; } else { if (fun->expression.params_count != paramcount) { - parseerror(parser, "expected %i parameters, got %i", (int)fun->expression.params_count, paramcount); - return false; + ast_value *fval; + fval = (ast_istype(fun, ast_value) ? ((ast_value*)fun) : NULL); + if (opts_standard == COMPILER_GMQCC) + { + if (fval) + parseerror(parser, "too few parameters for call to %s: expected %i, got %i", + fval->name, (int)fun->expression.params_count, paramcount); + else + parseerror(parser, "too few parameters for function call: expected %i, got %i", + (int)fun->expression.params_count, paramcount); + return false; + } + else + { + if (fval) + return parsewarning(parser, WARN_TOO_FEW_PARAMETERS, + "too few parameters for call to %s: expected %i, got %i", + fval->name, (int)fun->expression.params_count, paramcount); + else + return parsewarning(parser, WARN_TOO_FEW_PARAMETERS, + "too few parameters for function call: expected %i, got %i", + (int)fun->expression.params_count, paramcount); + } } } @@ -1617,7 +1638,7 @@ static bool parser_parse_statement(parser_t *parser, ast_block *block, ast_expre parseerror(parser, "parse error"); if (expected->expression.next->expression.vtype != TYPE_VOID) { if (opts_standard != COMPILER_GMQCC) - parsewarning(parser, WARN_MISSING_RETURN_VALUES, "return without value"); + (void)!parsewarning(parser, WARN_MISSING_RETURN_VALUES, "return without value"); else parseerror(parser, "return without value"); } diff --git a/warns.def b/warns.def index 030e938..88b4cfc 100644 --- a/warns.def +++ b/warns.def @@ -8,3 +8,4 @@ GMQCC_DEFINE_FLAG(UNKNOWN_CONTROL_SEQUENCE) GMQCC_DEFINE_FLAG(EXTENSIONS) GMQCC_DEFINE_FLAG(FIELD_REDECLARED) GMQCC_DEFINE_FLAG(MISSING_RETURN_VALUES) +GMQCC_DEFINE_FLAG(TOO_FEW_PARAMETERS)