mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-21 10:51:10 +00:00
Allow 'const' within function bodies
This commit is contained in:
parent
36cdffe1b3
commit
22173df7bd
1 changed files with 5 additions and 2 deletions
7
parser.c
7
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;
|
||||
|
|
Loading…
Reference in a new issue