aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_function.cpp
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2011-01-21 13:44:08 -0800
committerChad Versace <[email protected]>2011-01-21 14:06:28 -0800
commitb66be7518ad57368b31b5d70a2bb4c0fe66aa988 (patch)
tree14e6cec0ccece4c61725aafef35a89114411846f /src/glsl/ast_function.cpp
parent01a584d09350d2c726312e2c9e88c5dbc54bdb70 (diff)
glsl: Improve error message when read-only vars are written
Improves the cases when: * an explicit assignment references the read-only variable * an 'out' or 'inout' function parameter references the read-only variable
Diffstat (limited to 'src/glsl/ast_function.cpp')
-rw-r--r--src/glsl/ast_function.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 6ecf779c935..3e5e345389a 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -145,12 +145,27 @@ match_function_by_name(exec_list *instructions, const char *name,
if ((formal->mode == ir_var_out)
|| (formal->mode == ir_var_inout)) {
- if (! actual->is_lvalue()) {
- /* FINISHME: Log a better diagnostic here. There is no way
- * FINISHME: to tell the user which parameter is invalid.
- */
- _mesa_glsl_error(loc, state, "`%s' parameter is not lvalue",
- (formal->mode == ir_var_out) ? "out" : "inout");
+ const char *mode = NULL;
+ switch (formal->mode) {
+ case ir_var_out: mode = "out"; break;
+ case ir_var_inout: mode = "inout"; break;
+ default: assert(false); break;
+ }
+ /* FIXME: 'loc' is incorrect (as of 2011-01-21). It is always
+ * FIXME: 0:0(0).
+ */
+ if (actual->variable_referenced()
+ && actual->variable_referenced()->read_only) {
+ _mesa_glsl_error(loc, state,
+ "function parameter '%s %s' references the "
+ "read-only variable '%s'",
+ mode, formal->name,
+ actual->variable_referenced()->name);
+
+ } else if (!actual->is_lvalue()) {
+ _mesa_glsl_error(loc, state,
+ "function parameter '%s %s' is not an lvalue",
+ mode, formal->name);
}
}