Mesa (main): glsl: fix variable scope for instructions inside case statements

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 20 16:42:16 UTC 2021


Module: Mesa
Branch: main
Commit: 02b394023b74620092c45734dcdb531e97d6f19d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=02b394023b74620092c45734dcdb531e97d6f19d

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Wed Aug 18 13:57:14 2021 +1000

glsl: fix variable scope for instructions inside case statements

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

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

Reviewed-by: Marcin Ślusarz <marcin.slusarz at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12435>

---

 src/compiler/glsl/ast_to_hir.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 370f6934bd4..cb9dd0dbd99 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -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;



More information about the mesa-commit mailing list