Mesa (staging/21.2): glsl: fix variable scope for instructions inside case statements

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 23 17:44:10 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: a3aa3c5a53b3cd88fe485a1ad080d268458da14a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3aa3c5a53b3cd88fe485a1ad080d268458da14a

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>
(cherry picked from commit 02b394023b74620092c45734dcdb531e97d6f19d)

---

 .pick_status.json                | 2 +-
 src/compiler/glsl/ast_to_hir.cpp | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b4ea14439ab..1c0a834c4cd 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -472,7 +472,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"
     },
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