]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Fix 'declaration does not declare anything' regression i.e this closes #132.
authorDale Weiler <killfieldengine@gmail.com>
Thu, 17 Oct 2013 09:06:09 +0000 (05:06 -0400)
committerDale Weiler <killfieldengine@gmail.com>
Thu, 17 Oct 2013 09:06:09 +0000 (05:06 -0400)
parser.c

index 4c74fddf1046ad99d1239e1a37e759ee1b8f05cc..82ce53b0a47a84deeb0b422fc32c1558c8412681 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -4841,8 +4841,14 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va
     }
 
     /* there may be a name now */
-    if (parser->tok == TOKEN_IDENT) {
+    if (parser->tok == TOKEN_IDENT || parser->tok == TOKEN_KEYWORD) {
+        if (!strcmp(parser_tokval(parser), "break"))
+            (void)!parsewarning(parser, WARN_BREAKDEF, "break definition ignored (suggest removing it)");
+        else if (parser->tok == TOKEN_KEYWORD)
+            goto leave;
+
         name = util_strdup(parser_tokval(parser));
+
         /* parse on */
         if (!parser_next(parser)) {
             ast_delete(var);
@@ -4852,6 +4858,7 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_va
         }
     }
 
+    leave:
     /* now this may be an array */
     if (parser->tok == '[') {
         wasarray = true;
@@ -5571,16 +5578,8 @@ skipvar:
 
         if (parser->tok != '{' || var->expression.vtype != TYPE_FUNCTION) {
             if (parser->tok != '=') {
-                if (!strcmp(parser_tokval(parser), "break")) {
-                    if (!parser_next(parser)) {
-                        parseerror(parser, "error parsing break definition");
-                        break;
-                    }
-                    (void)!parsewarning(parser, WARN_BREAKDEF, "break definition ignored (suggest removing it)");
-                } else {
-                    parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
-                    break;
-                }
+                parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
+                break;
             }
 
             if (!parser_next(parser)) {