[Mesa-dev] [PATCH 3/7] glsl: Forbid opaque variables as operands of the ternary operator.

Francisco Jerez currojerez at riseup.net
Sat Jan 31 12:54:25 PST 2015


---
 src/glsl/ast_to_hir.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 1ba29f7..783384e 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1596,6 +1596,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();
       ir_constant *then_val = op[1]->constant_expression_value();
       ir_constant *else_val = op[2]->constant_expression_value();
-- 
2.1.3



More information about the mesa-dev mailing list