diff options
author | Zebediah Figura <zfigura@codeweavers.com> | 2021-09-14 06:40:09 +0300 |
---|---|---|
committer | Giovanni Mascellani <gmascellani@codeweavers.com> | 2022-07-26 15:48:52 +0300 |
commit | b7b802ebc0242e1d496d760d311f819215aea816 (patch) | |
tree | a4bb91dd1f8514a9dc6b22b01ace4e3fb1ad645f | |
parent | 7cbcb40a2f8021768efb24d69df2ff8fc7470278 (diff) |
vkd3d-shader/hlsl: Allow the final expression in a for loop initializer to be omitted.
-rw-r--r-- | libs/vkd3d-shader/hlsl.y | 14 | ||||
-rw-r--r-- | tests/return.shader_test | 8 |
2 files changed, 13 insertions, 9 deletions
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ee29fdd9..2c43b30a 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -3164,6 +3164,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl %type <list> declaration_statement %type <list> equality_expr %type <list> expr +%type <list> expr_optional %type <list> expr_statement %type <list> initializer_expr %type <list> jump_statement @@ -4319,24 +4320,27 @@ loop_statement: { $$ = create_loop(ctx, LOOP_DO_WHILE, NULL, $5, NULL, $2, @1); } - | KW_FOR '(' scope_start expr_statement expr_statement expr ')' statement + | KW_FOR '(' scope_start expr_statement expr_statement expr_optional ')' statement { $$ = create_loop(ctx, LOOP_FOR, $4, $5, $6, $8, @1); hlsl_pop_scope(ctx); } - | KW_FOR '(' scope_start declaration expr_statement expr ')' statement + | KW_FOR '(' scope_start declaration expr_statement expr_optional ')' statement { $$ = create_loop(ctx, LOOP_FOR, $4, $5, $6, $8, @1); hlsl_pop_scope(ctx); } -expr_statement: - ';' +expr_optional: + %empty { if (!($$ = make_empty_list(ctx))) YYABORT; } - | expr ';' + | expr + +expr_statement: + expr_optional ';' { $$ = $1; } diff --git a/tests/return.shader_test b/tests/return.shader_test index 9bd3642e..afdbb4c4 100644 --- a/tests/return.shader_test +++ b/tests/return.shader_test @@ -162,7 +162,7 @@ void main(out float4 ret : sv_target) } [test] -todo draw quad +draw quad todo probe all rgba (0.2, 0.4, 0.6, 0.8) [pixel shader] @@ -230,11 +230,11 @@ void main(out float4 ret : sv_target) [test] uniform 0 float 0.2 -todo draw quad +draw quad todo probe all rgba (0.2, 0.2, 0.2, 0.2) uniform 0 float 0.8 -todo draw quad -todo probe all rgba (0.5, 0.5, 0.5, 0.5) +draw quad +probe all rgba (0.5, 0.5, 0.5, 0.5) [pixel shader] |