glsl: Forbid opaque variables as operands of the ternary operator.
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 4 Dec 2014 08:42:11 +0000 (10:42 +0200)
committerFrancisco Jerez <currojerez@riseup.net>
Mon, 4 May 2015 14:44:16 +0000 (17:44 +0300)
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/ast_to_hir.cpp

index 18b82e3bec992f3a305ad56398f22bdabfd52ff6..da063d5606b609a3feb56c3a17980802438b017b 100644 (file)
@@ -1558,6 +1558,18 @@ ast_expression::do_hir(exec_list *instructions,
          error_emitted = true;
       }
 
+      /* From section 4.1.7 of the GLSL 4.50 spec (Opaque Types):
+       *
+       *  "Except for array indexing, structure member selection, and
+       *   parentheses, opaque variables are not allowed to be operands in
+       *   expressions; such use results in a compile-time error."
+       */
+      if (type->contains_opaque()) {
+         _mesa_glsl_error(&loc, state, "opaque variables cannot be operands "
+                          "of the ?: operator");
+         error_emitted = true;
+      }
+
       ir_constant *cond_val = op[0]->constant_expression_value();
 
       if (then_instructions.is_empty()