mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-20 18:32:01 +00:00
properly in all situations where an array is part of a function's return type
This commit is contained in:
parent
86e42ad123
commit
9324a96f77
1 changed files with 6 additions and 2 deletions
8
parser.c
8
parser.c
|
@ -2354,7 +2354,8 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase)
|
|||
lex_ctx ctx;
|
||||
|
||||
const char *name = NULL;
|
||||
bool isfield = false;
|
||||
bool isfield = false;
|
||||
bool wasarray = false;
|
||||
|
||||
ctx = parser_ctx(parser);
|
||||
|
||||
|
@ -2420,6 +2421,7 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase)
|
|||
|
||||
/* now this may be an array */
|
||||
if (parser->tok == '[') {
|
||||
wasarray = true;
|
||||
var = parse_arraysize(parser, var);
|
||||
if (!var)
|
||||
return NULL;
|
||||
|
@ -2436,6 +2438,8 @@ static ast_value *parse_typename(parser_t *parser, ast_value **storebase)
|
|||
/* now there may be function parens again */
|
||||
if (parser->tok == '(' && opts_standard == COMPILER_QCC)
|
||||
parseerror(parser, "C-style function syntax is not allowed in -std=qcc");
|
||||
if (parser->tok == '(' && wasarray)
|
||||
parseerror(parser, "arrays as part of a return type is not supported");
|
||||
while (parser->tok == '(') {
|
||||
var = parse_parameter_list(parser, var);
|
||||
if (!var) {
|
||||
|
@ -2512,7 +2516,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
|
|||
}
|
||||
}
|
||||
if (parser->tok == '(' && wasarray) {
|
||||
parseerror(parser, "functions cannot return arrays");
|
||||
parseerror(parser, "arrays as part of a return type is not supported");
|
||||
/* we'll still parse the type completely for now */
|
||||
}
|
||||
/* for functions returning functions */
|
||||
|
|
Loading…
Reference in a new issue