On 23 December 2011 14:35, Ian Romanick <span dir="ltr">&lt;<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

From: Ian Romanick &lt;<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>&gt;<br>
<br>
Signed-off-by: Ian Romanick &lt;<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>&gt;<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=42755" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=42755</a><br>
---<br>
 src/glsl/ast_to_hir.cpp |   28 +++++++++++++++++++++-------<br>
 1 files changed, 21 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp<br>
index 9319313..7e0bd0d 100644<br>
--- a/src/glsl/ast_to_hir.cpp<br>
+++ b/src/glsl/ast_to_hir.cpp<br>
@@ -664,6 +664,7 @@ mark_whole_array_access(ir_rvalue *access)<br>
<br>
 ir_rvalue *<br>
 do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,<br>
+             const ast_expression *lhs_ast,<br>
              ir_rvalue *lhs, ir_rvalue *rhs, bool is_initializer,<br>
              YYLTYPE lhs_loc)<br></blockquote><div><br>Minor suggestion: Since the only reason we are passing lst_ast into this function is so that it can check the non_lvalue_description string, I&#39;d prefer if we just pass in the string directly rather than the object that contains it.  That would simplify the null check below, and it would make the purpose of passing in the extra data more obvious.  But I&#39;m not married to this idea; either way, the patch is:<br>

<br>Reviewed-by: Paul Berry &lt;<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>&gt; <br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


 {<br>
@@ -671,8 +672,13 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,<br>
    bool error_emitted = (lhs-&gt;type-&gt;is_error() || rhs-&gt;type-&gt;is_error());<br>
<br>
    if (!error_emitted) {<br>
-      if (lhs-&gt;variable_referenced() != NULL<br>
-          &amp;&amp; lhs-&gt;variable_referenced()-&gt;read_only) {<br>
+      if (lhs_ast != NULL &amp;&amp; lhs_ast-&gt;non_lvalue_description != NULL) {<br>
+         _mesa_glsl_error(&amp;lhs_loc, state,<br>
+                          &quot;assignment to %s&quot;,<br>
+                         lhs_ast-&gt;non_lvalue_description);<br>
+        error_emitted = true;<br>
+      } else if (lhs-&gt;variable_referenced() != NULL<br>
+                &amp;&amp; lhs-&gt;variable_referenced()-&gt;read_only) {<br>
          _mesa_glsl_error(&amp;lhs_loc, state,<br>
                           &quot;assignment to read-only variable &#39;%s&#39;&quot;,<br>
                           lhs-&gt;variable_referenced()-&gt;name);<br>
@@ -1030,7 +1036,8 @@ ast_expression::hir(exec_list *instructions,<br>
       op[0] = this-&gt;subexpressions[0]-&gt;hir(instructions, state);<br>
       op[1] = this-&gt;subexpressions[1]-&gt;hir(instructions, state);<br>
<br>
-      result = do_assignment(instructions, state, op[0], op[1], false,<br>
+      result = do_assignment(instructions, state, this-&gt;subexpressions[0],<br>
+                            op[0], op[1], false,<br>
                             this-&gt;subexpressions[0]-&gt;get_location());<br>
       error_emitted = result-&gt;type-&gt;is_error();<br>
       break;<br>
@@ -1310,6 +1317,7 @@ ast_expression::hir(exec_list *instructions,<br>
                                                   op[0], op[1]);<br>
<br>
       result = do_assignment(instructions, state,<br>
+                            this-&gt;subexpressions[0],<br>
                             op[0]-&gt;clone(ctx, NULL), temp_rhs, false,<br>
                             this-&gt;subexpressions[0]-&gt;get_location());<br>
       error_emitted = (op[0]-&gt;type-&gt;is_error());<br>
@@ -1335,6 +1343,7 @@ ast_expression::hir(exec_list *instructions,<br>
                                        op[0], op[1]);<br>
<br>
       result = do_assignment(instructions, state,<br>
+                            this-&gt;subexpressions[0],<br>
                             op[0]-&gt;clone(ctx, NULL), temp_rhs, false,<br>
                             this-&gt;subexpressions[0]-&gt;get_location());<br>
       error_emitted = type-&gt;is_error();<br>
@@ -1349,8 +1358,9 @@ ast_expression::hir(exec_list *instructions,<br>
                                &amp;loc);<br>
       ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this-&gt;oper],<br>
                                                    type, op[0], op[1]);<br>
-      result = do_assignment(instructions, state, op[0]-&gt;clone(ctx, NULL),<br>
-                             temp_rhs, false,<br>
+      result = do_assignment(instructions, state,<br>
+                            this-&gt;subexpressions[0],<br>
+                            op[0]-&gt;clone(ctx, NULL), temp_rhs, false,<br>
                              this-&gt;subexpressions[0]-&gt;get_location());<br>
       error_emitted = op[0]-&gt;type-&gt;is_error() || op[1]-&gt;type-&gt;is_error();<br>
       break;<br>
@@ -1365,8 +1375,9 @@ ast_expression::hir(exec_list *instructions,<br>
                                    state, &amp;loc);<br>
       ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this-&gt;oper],<br>
                                                    type, op[0], op[1]);<br>
-      result = do_assignment(instructions, state, op[0]-&gt;clone(ctx, NULL),<br>
-                             temp_rhs, false,<br>
+      result = do_assignment(instructions, state,<br>
+                            this-&gt;subexpressions[0],<br>
+                            op[0]-&gt;clone(ctx, NULL), temp_rhs, false,<br>
                              this-&gt;subexpressions[0]-&gt;get_location());<br>
       error_emitted = op[0]-&gt;type-&gt;is_error() || op[1]-&gt;type-&gt;is_error();<br>
       break;<br>
@@ -1476,6 +1487,7 @@ ast_expression::hir(exec_list *instructions,<br>
                                        op[0], op[1]);<br>
<br>
       result = do_assignment(instructions, state,<br>
+                            this-&gt;subexpressions[0],<br>
                             op[0]-&gt;clone(ctx, NULL), temp_rhs, false,<br>
                             this-&gt;subexpressions[0]-&gt;get_location());<br>
       error_emitted = op[0]-&gt;type-&gt;is_error();<br>
@@ -1503,6 +1515,7 @@ ast_expression::hir(exec_list *instructions,<br>
       result = get_lvalue_copy(instructions, op[0]-&gt;clone(ctx, NULL));<br>
<br>
       (void)do_assignment(instructions, state,<br>
+                         this-&gt;subexpressions[0],<br>
                          op[0]-&gt;clone(ctx, NULL), temp_rhs, false,<br>
                          this-&gt;subexpressions[0]-&gt;get_location());<br>
<br>
@@ -2370,6 +2383,7 @@ process_initializer(ir_variable *var, ast_declaration *decl,<br>
       const glsl_type *initializer_type;<br>
       if (!type-&gt;qualifier.flags.q.uniform) {<br>
         result = do_assignment(initializer_instructions, state,<br>
+                               NULL,<br>
                                lhs, rhs, true,<br>
                                type-&gt;get_location());<br>
         initializer_type = result-&gt;type;<br>
<span><font color="#888888">--<br>
1.7.6.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>