From: Wolfgang (Blub) Bumiller Date: Sun, 25 Nov 2012 20:08:30 +0000 (+0100) Subject: Allow 'const' within function bodies X-Git-Tag: 0.1.9~238 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=22173df7bd005d3447931cdebd1a52b5fa8500d1;p=xonotic%2Fgmqcc.git Allow 'const' within function bodies --- diff --git a/parser.c b/parser.c index 752d62a..0bedff2 100644 --- a/parser.c +++ b/parser.c @@ -2253,8 +2253,11 @@ static bool parse_statement(parser_t *parser, ast_block *block, ast_expression * } else if (parser->tok == TOKEN_KEYWORD) { - if (!strcmp(parser_tokval(parser), "local")) + if (!strcmp(parser_tokval(parser), "local") || + !strcmp(parser_tokval(parser), "const")) { + int cvq = parser_tokval(parser)[0] == 'c' ? CV_CONST : CV_VAR; + if (!block) { parseerror(parser, "cannot declare a local variable here"); return false; @@ -2263,7 +2266,7 @@ static bool parse_statement(parser_t *parser, ast_block *block, ast_expression * parseerror(parser, "expected variable declaration"); return false; } - if (!parse_variable(parser, block, true, CV_VAR, NULL)) + if (!parse_variable(parser, block, true, cvq, NULL)) return false; *out = NULL; return true;