vkd3d-shader/hlsl: Return an error expression when an invalid subscript is used.

This commit is contained in:
Elizabeth Figura 2024-08-29 12:48:23 -05:00 committed by Henri Verbeet
parent 7905c47765
commit bb74180659
Notes: Henri Verbeet 2024-10-28 18:10:10 +01:00
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1214
2 changed files with 12 additions and 11 deletions

View File

@ -4445,8 +4445,6 @@ static void hlsl_ctx_cleanup(struct hlsl_ctx *ctx)
rb_destroy(&ctx->functions, free_function_rb, NULL);
hlsl_block_cleanup(&ctx->static_initializers);
/* State blocks must be free before the variables, because they contain instructions that may
* refer to them. */
LIST_FOR_EACH_ENTRY_SAFE(scope, next_scope, &ctx->scopes, struct hlsl_scope, entry)
@ -4462,6 +4460,8 @@ static void hlsl_ctx_cleanup(struct hlsl_ctx *ctx)
}
}
hlsl_block_cleanup(&ctx->static_initializers);
LIST_FOR_EACH_ENTRY_SAFE(scope, next_scope, &ctx->scopes, struct hlsl_scope, entry)
{
LIST_FOR_EACH_ENTRY_SAFE(var, next_var, &scope->vars, struct hlsl_ir_var, scope_entry)

View File

@ -1243,7 +1243,8 @@ static bool add_record_access_recurse(struct hlsl_ctx *ctx, struct hlsl_block *b
}
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field \"%s\" is not defined.", name);
return false;
block->value = ctx->error_instr;
return true;
}
static bool add_typedef(struct hlsl_ctx *ctx, struct hlsl_type *const orig_type, struct list *list)
@ -8960,27 +8961,27 @@ postfix_expr:
vkd3d_free($3);
YYABORT;
}
vkd3d_free($3);
}
else if (hlsl_is_numeric_type(node->data_type))
{
struct hlsl_ir_node *swizzle;
if (!(swizzle = get_swizzle(ctx, node, $3, &@3)))
if ((swizzle = get_swizzle(ctx, node, $3, &@3)))
{
hlsl_block_add_instr($1, swizzle);
}
else
{
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle \"%s\".", $3);
vkd3d_free($3);
YYABORT;
$1->value = ctx->error_instr;
}
hlsl_block_add_instr($1, swizzle);
vkd3d_free($3);
}
else if (node->data_type->class != HLSL_CLASS_ERROR)
{
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript \"%s\".", $3);
vkd3d_free($3);
YYABORT;
$1->value = ctx->error_instr;
}
vkd3d_free($3);
$$ = $1;
}
| postfix_expr '[' expr ']'