GMQCC_DEFINE_FLAG(UNTYPED_NIL)
GMQCC_DEFINE_FLAG(PERMISSIVE)
GMQCC_DEFINE_FLAG(ENHANCED_DIAGNOSTICS)
+ GMQCC_DEFINE_FLAG(VARIADIC_ARGS)
#endif
/* warning flags */
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;
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"))
{
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;