glsl: Don't allow const on out or inout function parameters
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 8 Aug 2013 23:42:37 +0000 (16:42 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 9 Aug 2013 20:51:18 +0000 (13:51 -0700)
Fixes piglit tests const-inout-parameter.frag and
const-out-parameter.frag.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Cc: "9.2" <mesa-stable@lists.freedesktop.org>
src/glsl/ast_to_hir.cpp

index bfdf8e3791fbb9254dcaf936b2b2a59eb7e6ed58..c06051f6271db078c767642ce857abfe0f21be52 100644 (file)
@@ -1967,6 +1967,21 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
                       _mesa_glsl_shader_target_name(state->target));
    }
 
+   /* Section 6.1.1 (Function Calling Conventions) of the GLSL 1.10 spec says:
+    *
+    *     "However, the const qualifier cannot be used with out or inout."
+    *
+    * The same section of the GLSL 4.40 spec further clarifies this saying:
+    *
+    *     "The const qualifier cannot be used with out or inout, or a
+    *     compile-time error results."
+    */
+   if (is_parameter && qual->flags.q.constant && qual->flags.q.out) {
+      _mesa_glsl_error(loc, state,
+                       "`const' may not be applied to `out' or `inout' "
+                       "function parameters");
+   }
+
    /* If there is no qualifier that changes the mode of the variable, leave
     * the setting alone.
     */