From 663723f00aaa92a15f77bfd7f357ef78b052517d Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Wed, 7 Jul 2021 22:58:13 -0400 Subject: [PATCH] fixed mixing of old and new framemacro syntax --- parser.cpp | 4 ++-- tests/framemacro.qc | 20 ++++++++++++++++++++ tests/framemacro.tmpl | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/framemacro.qc create mode 100644 tests/framemacro.tmpl diff --git a/parser.cpp b/parser.cpp index 57fc7e2..0ca7843 100644 --- a/parser.cpp +++ b/parser.cpp @@ -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 index 0000000..1baf076 --- /dev/null +++ b/tests/framemacro.qc @@ -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 index 0000000..ee80044 --- /dev/null +++ b/tests/framemacro.tmpl @@ -0,0 +1,4 @@ +I: framemacro.qc +D: test frame macros +T: -compile +C: -std=gmqcc \ No newline at end of file -- 2.39.2