mesa: Branch 'master'

Brian Paul brianp at kemper.freedesktop.org
Fri Mar 30 13:59:07 PDT 2007


 src/mesa/shader/slang/slang_codegen.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletion(-)

New commits:
diff-tree e608d92c5b42d192772066194531db8bfaff86ce (from 57dadf71caab2fb85aad930e3e8df6cdc9db209a)
Author: Brian <brian at yutani.localnet.net>
Date:   Fri Mar 30 14:52:23 2007 -0600

    check that LHS of assignment is writable

diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 8a6da16..b1f6db8 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2140,6 +2140,26 @@ _slang_gen_swizzle(slang_ir_node *child,
 static slang_ir_node *
 _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
 {
+   if (oper->children[0].type == SLANG_OPER_IDENTIFIER) {
+      /* Check that var is writeable */
+      slang_variable *var
+         = _slang_locate_variable(oper->locals,
+                                  oper->children[0].a_id, GL_TRUE);
+      if (!var) {
+         slang_info_log_error(A->log, "undefined variable '%s'",
+                              (char *) oper->children[0].a_id);
+         return NULL;
+      }
+      if (var->type.qualifier == SLANG_QUAL_CONST ||
+          var->type.qualifier == SLANG_QUAL_ATTRIBUTE ||
+          var->type.qualifier == SLANG_QUAL_UNIFORM) {
+         slang_info_log_error(A->log,
+                              "illegal assignment to read-only variable '%s'",
+                              (char *) oper->children[0].a_id);
+         return NULL;
+      }
+   }
+
    if (oper->children[0].type == SLANG_OPER_IDENTIFIER &&
        oper->children[1].type == SLANG_OPER_CALL) {
       /* Special case of:  x = f(a, b)
@@ -2164,7 +2184,8 @@ _slang_gen_assignment(slang_assemble_ctx
              lhs->Store->File != PROGRAM_TEMPORARY &&
              lhs->Store->File != PROGRAM_VARYING &&
              lhs->Store->File != PROGRAM_UNDEFINED) {
-            slang_info_log_error(A->log, "Assignment to read-only variable");
+            slang_info_log_error(A->log,
+                                 "illegal assignment to read-only l-value");
             return NULL;
          }
       }


More information about the mesa-commit mailing list