X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=parser.c;h=506f8d201fd812fccafce45c03930a29b5c178af;hb=b3e9ef3ad9f8f9aee8c3472efd2c4485dc684718;hp=7034e64c7314ede34e1d65878c7b71c746efa40e;hpb=aed2b1031c6466a2dbcf909faeac1ac1cff0f6e6;p=xonotic%2Fgmqcc.git diff --git a/parser.c b/parser.c index 7034e64..506f8d2 100644 --- a/parser.c +++ b/parser.c @@ -5623,7 +5623,7 @@ skipvar: } } - if (parser->tok != '{') { + if (parser->tok != '{' || var->expression.vtype != TYPE_FUNCTION) { if (parser->tok != '=') { parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser)); break; @@ -5639,11 +5639,11 @@ skipvar: } if (parser->tok == '#') { - ast_function *func = NULL; - ast_value *number = NULL; - float fractional = 0; - float integral = 0; - int builtin_num = 0; + ast_function *func = NULL; + ast_value *number = NULL; + float fractional; + float integral; + int builtin_num; if (localblock) { parseerror(parser, "cannot declare builtins within functions"); @@ -5689,7 +5689,9 @@ skipvar: /* we only want the integral part anyways */ builtin_num = integral; - } else if (parser->tok != TOKEN_INTCONST) { + } else if (parser->tok == TOKEN_INTCONST) { + builtin_num = parser_token(parser)->constval.i; + } else { parseerror(parser, "builtin number must be a compile time constant"); break; } @@ -5709,9 +5711,7 @@ skipvar: } vec_push(parser->functions, func); - func->builtin = -((OPTS_FLAG(EXPRESSIONS_FOR_BUILTINS)) - ? builtin_num - : parser_token(parser)->constval.i) - 1; + func->builtin = -builtin_num-1; } if (OPTS_FLAG(EXPRESSIONS_FOR_BUILTINS)