From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 17 ++++++++++++++++- tests/hlsl-invalid.shader_test | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 2d0343a56..4daeda442 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1108,6 +1108,21 @@ static unsigned int evaluate_static_expression_as_uint(struct hlsl_ctx *ctx, str unsigned int ret = 0; bool progress;
+ LIST_FOR_EACH_ENTRY(node, &block->instrs, struct hlsl_ir_node, entry) + { + switch (node->type) + { + case HLSL_IR_CONSTANT: + case HLSL_IR_EXPR: + case HLSL_IR_SWIZZLE: + case HLSL_IR_LOAD: + continue; + default: + hlsl_error(ctx, &node->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, + "Expected literal expression."); + } + } + if (!hlsl_clone_block(ctx, &expr, &ctx->static_initializers)) return 0; hlsl_block_add_block(&expr, block); @@ -1134,7 +1149,7 @@ static unsigned int evaluate_static_expression_as_uint(struct hlsl_ctx *ctx, str else { hlsl_error(ctx, &node->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, - "Failed to evaluate constant expression %d.", node->type); + "Failed to evaluate constant expression."); }
hlsl_block_cleanup(&expr); diff --git a/tests/hlsl-invalid.shader_test b/tests/hlsl-invalid.shader_test index 61033811d..ad0626520 100644 --- a/tests/hlsl-invalid.shader_test +++ b/tests/hlsl-invalid.shader_test @@ -72,7 +72,7 @@ float4 main() : sv_target return 0; }
-[pixel shader fail todo] +[pixel shader fail] float4 main() : sv_target { int x;