From a77dca528acacbf03af650e13c347c23f26cc212 Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Thu, 23 Jan 2025 19:38:42 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Forbid declaring const variables with no initializer. --- libs/vkd3d-shader/hlsl.y | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 492b9dee..9d14d051 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -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, "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) {