On 23 December 2011 14:35, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></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 <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><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'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'm not married to this idea; either way, the patch is:<br>
<br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>> <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->type->is_error() || rhs->type->is_error());<br>
<br>
if (!error_emitted) {<br>
- if (lhs->variable_referenced() != NULL<br>
- && lhs->variable_referenced()->read_only) {<br>
+ if (lhs_ast != NULL && lhs_ast->non_lvalue_description != NULL) {<br>
+ _mesa_glsl_error(&lhs_loc, state,<br>
+ "assignment to %s",<br>
+ lhs_ast->non_lvalue_description);<br>
+ error_emitted = true;<br>
+ } else if (lhs->variable_referenced() != NULL<br>
+ && lhs->variable_referenced()->read_only) {<br>
_mesa_glsl_error(&lhs_loc, state,<br>
"assignment to read-only variable '%s'",<br>
lhs->variable_referenced()->name);<br>
@@ -1030,7 +1036,8 @@ ast_expression::hir(exec_list *instructions,<br>
op[0] = this->subexpressions[0]->hir(instructions, state);<br>
op[1] = this->subexpressions[1]->hir(instructions, state);<br>
<br>
- result = do_assignment(instructions, state, op[0], op[1], false,<br>
+ result = do_assignment(instructions, state, this->subexpressions[0],<br>
+ op[0], op[1], false,<br>
this->subexpressions[0]->get_location());<br>
error_emitted = result->type->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->subexpressions[0],<br>
op[0]->clone(ctx, NULL), temp_rhs, false,<br>
this->subexpressions[0]->get_location());<br>
error_emitted = (op[0]->type->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->subexpressions[0],<br>
op[0]->clone(ctx, NULL), temp_rhs, false,<br>
this->subexpressions[0]->get_location());<br>
error_emitted = type->is_error();<br>
@@ -1349,8 +1358,9 @@ ast_expression::hir(exec_list *instructions,<br>
&loc);<br>
ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper],<br>
type, op[0], op[1]);<br>
- result = do_assignment(instructions, state, op[0]->clone(ctx, NULL),<br>
- temp_rhs, false,<br>
+ result = do_assignment(instructions, state,<br>
+ this->subexpressions[0],<br>
+ op[0]->clone(ctx, NULL), temp_rhs, false,<br>
this->subexpressions[0]->get_location());<br>
error_emitted = op[0]->type->is_error() || op[1]->type->is_error();<br>
break;<br>
@@ -1365,8 +1375,9 @@ ast_expression::hir(exec_list *instructions,<br>
state, &loc);<br>
ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper],<br>
type, op[0], op[1]);<br>
- result = do_assignment(instructions, state, op[0]->clone(ctx, NULL),<br>
- temp_rhs, false,<br>
+ result = do_assignment(instructions, state,<br>
+ this->subexpressions[0],<br>
+ op[0]->clone(ctx, NULL), temp_rhs, false,<br>
this->subexpressions[0]->get_location());<br>
error_emitted = op[0]->type->is_error() || op[1]->type->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->subexpressions[0],<br>
op[0]->clone(ctx, NULL), temp_rhs, false,<br>
this->subexpressions[0]->get_location());<br>
error_emitted = op[0]->type->is_error();<br>
@@ -1503,6 +1515,7 @@ ast_expression::hir(exec_list *instructions,<br>
result = get_lvalue_copy(instructions, op[0]->clone(ctx, NULL));<br>
<br>
(void)do_assignment(instructions, state,<br>
+ this->subexpressions[0],<br>
op[0]->clone(ctx, NULL), temp_rhs, false,<br>
this->subexpressions[0]->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->qualifier.flags.q.uniform) {<br>
result = do_assignment(initializer_instructions, state,<br>
+ NULL,<br>
lhs, rhs, true,<br>
type->get_location());<br>
initializer_type = result->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>