X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=parser.c;h=3ed0f08eeeaaa61ff9cdc089f405c9307a059bbe;hp=4459d7b1bdc336ed4c01c7c6580527f77d302978;hb=3ecae267adeb4395d6f6df7ebb05cd56fc03bfb8;hpb=7dd31ccf77f2b7dd85c0ea227f6d1e041f15de37 diff --git a/parser.c b/parser.c index 4459d7b..3ed0f08 100644 --- a/parser.c +++ b/parser.c @@ -1713,6 +1713,10 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma else if (parser->tok == TOKEN_DOTS) { ast_expression *va; + if (!OPTS_FLAG(VARIADIC_ARGS)) { + parseerror(parser, "cannot access varargs (try -fvariadic-args)"); + goto onerr; + } if (wantop) { parseerror(parser, "expected operator or end of statement"); goto onerr; @@ -1791,7 +1795,7 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma * We should also consider adding correction tables for * other things as well. */ - if (OPTS_FLAG(ENHANCED_DIAGNOSTICS)) { + if (opts.correction) { correction_t corr; correct_init(&corr); @@ -3776,7 +3780,7 @@ static bool parse_function_body(parser_t *parser, ast_value *var) return false; } - if (var->expression.flags & AST_FLAG_VARIADIC) { + if (!OPTS_FLAG(VARIADIC_ARGS) && var->expression.flags & AST_FLAG_VARIADIC) { if (parsewarning(parser, WARN_VARIADIC_FUNCTION, "variadic function with implementation will not be able to access additional parameters")) { @@ -4012,7 +4016,7 @@ static bool parse_function_body(parser_t *parser, ast_value *var) func->argc = argc; } - if (var->expression.flags & AST_FLAG_VARIADIC) { + if (OPTS_FLAG(VARIADIC_ARGS) && var->expression.flags & AST_FLAG_VARIADIC) { char name[1024]; ast_value *varargs = ast_value_new(ast_ctx(var), "reserved:va_args", TYPE_ARRAY); varargs->expression.flags |= AST_FLAG_IS_VARARG;