glsl: fix variable scope for do-while loops
Without this the following code was successfully compiling.
void main()
{
do
int var_1 = 0;
while (false);
var_1++;
}
Fixes: a87ac255cf
("Initial commit. lol")
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12465>
This commit is contained in:
parent
174c057926
commit
52893327fb
|
@ -7141,9 +7141,16 @@ ast_iteration_statement::hir(exec_list *instructions,
|
|||
if (rest_expression != NULL)
|
||||
rest_expression->hir(&rest_instructions, state);
|
||||
|
||||
if (body != NULL)
|
||||
if (body != NULL) {
|
||||
if (mode == ast_do_while)
|
||||
state->symbols->push_scope();
|
||||
|
||||
body->hir(& stmt->body_instructions, state);
|
||||
|
||||
if (mode == ast_do_while)
|
||||
state->symbols->pop_scope();
|
||||
}
|
||||
|
||||
if (rest_expression != NULL)
|
||||
stmt->body_instructions.append_list(&rest_instructions);
|
||||
|
||||
|
|
|
@ -2743,7 +2743,7 @@ iteration_statement:
|
|||
NULL, $3, NULL, $5);
|
||||
$$->set_location_range(@1, @4);
|
||||
}
|
||||
| DO statement WHILE '(' expression ')' ';'
|
||||
| DO statement_no_new_scope WHILE '(' expression ')' ';'
|
||||
{
|
||||
void *ctx = state->linalloc;
|
||||
$$ = new(ctx) ast_iteration_statement(ast_iteration_statement::ast_do_while,
|
||||
|
|
Loading…
Reference in New Issue