]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
fixed mixing of old and new framemacro syntax
authorDale Weiler <weilercdale@gmail.com>
Thu, 8 Jul 2021 02:58:13 +0000 (22:58 -0400)
committerDale Weiler <weilercdale@gmail.com>
Thu, 8 Jul 2021 02:58:13 +0000 (22:58 -0400)
parser.cpp
tests/framemacro.qc [new file with mode: 0644]
tests/framemacro.tmpl [new file with mode: 0644]

index 57fc7e2257e99921d60196d140be0ce659ab66d1..0ca7843a37c214a3e3189ff1f39474694678c28f 100644 (file)
@@ -5180,7 +5180,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
             }
         }
         /* we only allow 1-dimensional arrays */
-        if (parser->tok == '[') {
+        if (var->m_vtype != TYPE_FUNCTION && parser->tok == '[') {
             wasarray = true;
             var = parse_arraysize(parser, var);
             if (!var) {
@@ -5618,7 +5618,7 @@ skipvar:
             }
         }
 
-        if (parser->tok != '{' || var->m_vtype != TYPE_FUNCTION) {
+        if (var->m_vtype != TYPE_FUNCTION || (parser->tok != '{' && parser->tok != '[')) {
             if (parser->tok != '=') {
                 parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
                 break;
diff --git a/tests/framemacro.qc b/tests/framemacro.qc
new file mode 100644 (file)
index 0000000..1baf076
--- /dev/null
@@ -0,0 +1,20 @@
+$frame frame1 frame2
+
+float time;
+entity self;
+.float frame;
+.float nextthink;
+.void() think;
+
+// Mixing syntax, = is optional.
+void frame1_func_mixed_no_assign() [$frame1, frame2_func_mixed_no_assign] {}
+void frame2_func_mixed_no_assign() [$frame2, frame2_func_mixed_no_assign] {}
+
+void frame1_func_mixed() =[$frame1, frame2_func_mixed] {}
+void frame2_func_mixed() =[$frame2, frame2_func_mixed] {}
+
+void() frame1_func_old =[$frame1, frame2_func_old] {}
+void() frame2_func_old =[$frame2, frame2_func_old] {}
+
+
+
diff --git a/tests/framemacro.tmpl b/tests/framemacro.tmpl
new file mode 100644 (file)
index 0000000..ee80044
--- /dev/null
@@ -0,0 +1,4 @@
+I: framemacro.qc
+D: test frame macros
+T: -compile
+C: -std=gmqcc
\ No newline at end of file