summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_to_hir.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_to_hir.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_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index dfb016cf7d8..1bca3ecf12a 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -639,7 +639,14 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
bool error_emitted = (lhs->type->is_error() || rhs->type->is_error());
if (!error_emitted) {
- if (!lhs->is_lvalue()) {
+ if (lhs->variable_referenced() != NULL
+ && lhs->variable_referenced()->read_only) {
+ _mesa_glsl_error(&lhs_loc, state,
+ "assignment to read-only variable '%s'",
+ lhs->variable_referenced()->name);
+ error_emitted = true;
+
+ } else if (!lhs->is_lvalue()) {
_mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment");
error_emitted = true;
}