]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Allow 'const' within function bodies
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 25 Nov 2012 20:08:30 +0000 (21:08 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 25 Nov 2012 20:08:30 +0000 (21:08 +0100)
parser.c

index 752d62a2ad3c5358e119facce38d7aa5c6ca2a69..0bedff263139e6cc60d1b9aa60ce4c2ba8459288 100644 (file)
--- 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;