Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl.y:
$$ = create_loop(ctx, LOOP_DO_WHILE, &$1, NULL, $7, NULL, $4, &@3);
hlsl_pop_scope(ctx); }
- | attribute_list_optional KW_FOR '(' scope_start expr_statement expr_statement expr_optional ')' statement
- | attribute_list_optional loop_scope_start KW_FOR '(' expr_statement expr_statement expr_optional ')' statement {
$$ = create_loop(ctx, LOOP_FOR, &$1, $5, $6, $7, $9, &@2);
$$ = create_loop(ctx, LOOP_FOR, &$1, $5, $6, $7, $9, &@3); hlsl_pop_scope(ctx); }
- | attribute_list_optional KW_FOR '(' scope_start declaration expr_statement expr_optional ')' statement
- | attribute_list_optional loop_scope_start KW_FOR '(' declaration expr_statement expr_optional ')' statement {
$$ = create_loop(ctx, LOOP_FOR, &$1, $5, $6, $7, $9, &@2);
$$ = create_loop(ctx, LOOP_FOR, &$1, $5, $6, $7, $9, &@3); hlsl_pop_scope(ctx);
There is some problem with how loop scoping is handled here. For example, this is accepted by native and not by us: ``` float4 main() : sv_target { for (int y = 0; y < 1000; y++); return float4(y, 0.0, 0.0, 0.0); }
```
However this is broken also before this MR, so I'm not insisting on this, just wanted to mention it. I'm not sure right now on what is the best solution to handle scopes here, and the proposal doesn't look more broken than the current state, so it's ok for me.