Signed-off-by: Francisco Casas fcasas@codeweavers.com
--- v5: - Preserve array pointer to correctly free memory on realloc failure.
Signed-off-by: Francisco Casas fcasas@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index aca246f6..5f8841fe 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2411,6 +2411,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl %type <function> func_prototype
%type <initializer> complex_initializer +%type <initializer> complex_initializer_list %type <initializer> func_arguments %type <initializer> initializer_expr_list
@@ -3218,15 +3219,35 @@ complex_initializer: $$.args[0] = node_from_list($1); $$.instrs = $1; } - | '{' initializer_expr_list '}' + | '{' complex_initializer_list '}' { $$ = $2; } - | '{' initializer_expr_list ',' '}' + | '{' complex_initializer_list ',' '}' { $$ = $2; }
+complex_initializer_list: + complex_initializer + | complex_initializer_list ',' complex_initializer + { + struct hlsl_ir_node **new_args; + + $$ = $1; + if (!(new_args = hlsl_realloc(ctx, $$.args, ($$.args_count + $3.args_count) * sizeof(*$$.args)))) + { + free_parse_initializer(&$$); + free_parse_initializer(&$3); + YYABORT; + } + $$.args = new_args; + for (unsigned int i = 0; i < $3.args_count; i++) + $$.args[$$.args_count++] = $3.args[i]; + list_move_tail($$.instrs, $3.instrs); + free_parse_initializer(&$3); + } + initializer_expr: assignment_expr
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- But only after the declaration of "unsigned int i" is moved out of the for initialization clause.
Il 10/03/22 16:14, Francisco Casas ha scritto:
Signed-off-by: Francisco Casas fcasas@codeweavers.com
v5:
- Preserve array pointer to correctly free memory on realloc failure.
Signed-off-by: Francisco Casas fcasas@codeweavers.com
libs/vkd3d-shader/hlsl.y | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index aca246f6..5f8841fe 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2411,6 +2411,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl %type <function> func_prototype
%type <initializer> complex_initializer +%type <initializer> complex_initializer_list %type <initializer> func_arguments %type <initializer> initializer_expr_list
@@ -3218,15 +3219,35 @@ complex_initializer: $$.args[0] = node_from_list($1); $$.instrs = $1; }
- | '{' initializer_expr_list '}'
- | '{' complex_initializer_list '}' { $$ = $2; }
- | '{' initializer_expr_list ',' '}'
- | '{' complex_initializer_list ',' '}' { $$ = $2; }
+complex_initializer_list:
complex_initializer
- | complex_initializer_list ',' complex_initializer
{
struct hlsl_ir_node **new_args;
$$ = $1;
if (!(new_args = hlsl_realloc(ctx, $$.args, ($$.args_count + $3.args_count) * sizeof(*$$.args))))
{
free_parse_initializer(&$$);
free_parse_initializer(&$3);
YYABORT;
}
$$.args = new_args;
for (unsigned int i = 0; i < $3.args_count; i++)
$$.args[$$.args_count++] = $3.args[i];
list_move_tail($$.instrs, $3.instrs);
free_parse_initializer(&$3);
}
- initializer_expr: assignment_expr