glsl: fix variable scope for instructions inside case statements

Fixes: 665d75cc5a ("glsl: Fix scoping bug in if statements.")

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5247

Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12435>
(cherry picked from commit 02b394023b)
This commit is contained in:
Timothy Arceri 2021-08-18 13:57:14 +10:00 committed by Eric Engestrom
parent ef6f4d897c
commit b48ac0e29b
2 changed files with 5 additions and 2 deletions

View file

@ -337,7 +337,7 @@
"description": "glsl: fix variable scope for instructions inside case statements",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "665d75cc5a23f8024034d0c4176fb281f94a30e9"
},

View file

@ -6830,8 +6830,11 @@ ir_rvalue *
ast_switch_body::hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
{
if (stmts != NULL)
if (stmts != NULL) {
state->symbols->push_scope();
stmts->hir(instructions, state);
state->symbols->pop_scope();
}
/* Switch bodies do not have r-values. */
return NULL;