vkd3d-shader/hlsl: Forbid declaring const variables with no initializer.

This commit is contained in:
Shaun Ren
2025-01-23 19:38:42 -05:00
committed by Henri Verbeet
parent 25c6d16b45
commit a77dca528a
Notes: Henri Verbeet 2025-01-29 18:04:29 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Francisco Casas (@fcasas)
Approved-by: Elizabeth Figura (@zfigura)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1355

View File

@ -2717,6 +2717,12 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RESERVATION,
"packoffset() is only allowed inside constant buffer declarations."); "packoffset() is only allowed inside constant buffer declarations.");
} }
else
{
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count)
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER,
"Const variable \"%s\" is missing an initializer.", var->name);
}
if (ctx->cur_scope == ctx->globals) if (ctx->cur_scope == ctx->globals)
{ {