Mesa (7.10): glsl: Set operators '%' and '%=' to be reserved when GLSL < 1. 30

Ian Romanick idr at kemper.freedesktop.org
Tue Mar 1 00:01:37 UTC 2011


Module: Mesa
Branch: 7.10
Commit: 89576ea75b06681081883f0f9c5a2e0e2d44c837
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=89576ea75b06681081883f0f9c5a2e0e2d44c837

Author: Chad Versace <chad.versace at intel.com>
Date:   Fri Feb  4 12:18:56 2011 -0800

glsl: Set operators '%' and '%=' to be reserved when GLSL < 1.30

>From section 5.9 of the GLSL 1.20 spec:
   The operator modulus (%) is reserved for future use.

>From section 5.8 of the GLSL 1.20 spec:
   The assignments modulus into (%=), left shift by (<<=), right shift by
   (>>=), inclusive or into ( |=), and exclusive or into ( ^=). These
   operators are reserved for future use.

The GLSL ES 1.00 spec and GLSL 1.10 spec have similiar language.

Fixes bug:
https://bugs.freedesktop.org//show_bug.cgi?id=33916

Fixes Piglit tests:
spec/glsl-1.00/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.00/compiler/assignment-operators/modulus-assign-00.frag
spec/glsl-1.10/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.10/compiler/assignment-operators/modulus-assign-00.frag
spec/glsl-1.20/compiler/arithmetic-operators/modulus-00.frag
spec/glsl-1.20/compiler/assignment-operators/modulus-assign-00.frag
(cherry picked from commit 82f994f3860ca05ff5550f32844b0f523d40b9ef)

---

 src/glsl/ast_to_hir.cpp |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index e66016d..593f09d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -435,6 +435,13 @@ modulus_result_type(const struct glsl_type *type_a,
 		    const struct glsl_type *type_b,
 		    struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
 {
+   if (state->language_version < 130) {
+      _mesa_glsl_error(loc, state,
+                       "operator '%%' is reserved in %s",
+                       state->version_string);
+      return glsl_type::error_type;
+   }
+
    /* From GLSL 1.50 spec, page 56:
     *    "The operator modulus (%) operates on signed or unsigned integers or
     *    integer vectors. The operand types must both be signed or both be




More information about the mesa-commit mailing list