glsl: Reject non-scalar switch expressions.
authorEric Anholt <eric@anholt.net>
Mon, 14 May 2012 15:45:59 +0000 (08:45 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 17 May 2012 17:05:24 +0000 (10:05 -0700)
The comment quotes spec saying that only scalar integers are allowed,
but we only checked for integer.

Fixes piglit switch-expression-const-ivec2.vert

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/ast_to_hir.cpp

index 513908a..c59e5e6 100644 (file)
@@ -3521,11 +3521,9 @@ ast_switch_statement::hir(exec_list *instructions,
     *
     *    "The type of init-expression in a switch statement must be a 
     *     scalar integer." 
-    *
-    * The checks are separated so that higher quality diagnostics can be
-    * generated for cases where the rule is violated.
     */
-   if (!test_expression->type->is_integer()) {
+   if (!test_expression->type->is_scalar() ||
+       !test_expression->type->is_integer()) {
       YYLTYPE loc = this->test_expression->get_location();
 
       _mesa_glsl_error(& loc,