]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
implement correct behaviour for shadows locals
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 19:56:42 +0000 (21:56 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 18 Aug 2012 19:56:42 +0000 (21:56 +0200)
parser.c

index 567a622f6a73197ee5cbd7ca6b319d51c1f88ed6..fa910692443b770651e9531071f1517fd463e887 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1842,20 +1842,20 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
                 {
                     if (olddecl)
                     {
+                        ast_value_delete(var);
                         if (isparam &&
                             parsewarning(parser, WARN_LOCAL_SHADOWS,
                                          "a parameter is shadowing local `%s`", parser_tokval(parser)))
                         {
-                            ast_value_delete(var);
                             return false;
                         }
                         else if (!isparam)
                         {
-                            ast_value_delete(var);
                             parseerror(parser, "local `%s` already declared here: %s:%i",
                                        parser_tokval(parser), ast_ctx(olddecl).file, (int)ast_ctx(olddecl).line);
                             return false;
                         }
+                        goto nextvar;
                     }
                 }
             }
@@ -2010,6 +2010,7 @@ static bool parser_variable(parser_t *parser, ast_block *localblock)
             }
         }
 
+nextvar:
         if (!parser_next(parser)) {
             ast_value_delete(var);
             return false;