[Mesa-dev] [PATCH] glsl: type check between switch init-expression and case

Tapani Pälli tapani.palli at intel.com
Mon Jun 9 04:29:25 PDT 2014


Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79724
---
 src/glsl/ast_to_hir.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index d1c77f1..131b25f 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4629,6 +4629,15 @@ ast_case_label::hir(exec_list *instructions,
          }
       }
 
+      /* Check that types match (no implicit conversions allowed). */
+      if (label_const->type != state->switch_state.test_var->type) {
+         YYLTYPE loc = this->test_value->get_location();
+         _mesa_glsl_error(&loc, state,
+                          "type mismatch with switch init-expression and case "
+                          "label (%s != %s)", label_const->type->name,
+                          state->switch_state.test_var->type->name);
+      }
+
       ir_dereference_variable *deref_test_var =
          new(ctx) ir_dereference_variable(state->switch_state.test_var);
 
-- 
1.8.3.1



More information about the mesa-dev mailing list