<div dir="ltr">On 17 October 2013 04:42, Timothy Arceri <span dir="ltr"><<a href="mailto:t_arceri@yahoo.com.au" target="_blank">t_arceri@yahoo.com.au</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
 src/glsl/ast_to_hir.cpp | 27 ++++++++++++++-------------<br>
 1 file changed, 14 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp<br>
index dfa32d9..f96ed53 100644<br>
--- a/src/glsl/ast_to_hir.cpp<br>
+++ b/src/glsl/ast_to_hir.cpp<br>
@@ -637,8 +637,8 @@ shift_result_type(const struct glsl_type *type_a,<br>
  */<br>
 ir_rvalue *<br>
 validate_assignment(struct _mesa_glsl_parse_state *state,<br>
-                   const glsl_type *lhs_type, ir_rvalue *rhs,<br>
-                   bool is_initializer)<br>
+                    YYLTYPE loc, const glsl_type *lhs_type,<br>
+                    ir_rvalue *rhs, bool is_initializer)<br>
 {<br>
    /* If there is already some error in the RHS, just return it.  Anything<br>
     * else will lead to an avalanche of error message back to the user.<br>
@@ -670,6 +670,12 @@ validate_assignment(struct _mesa_glsl_parse_state *state,<br>
         return rhs;<br>
    }<br>
<br>
+   _mesa_glsl_error(&loc, state,<br>
+                    is_initializer ? "initializer" : "value"<br>
+                    " of type %s cannot be assigned to "<br>
+                    "variable of type %s",<br>
+                    rhs->type->name, lhs_type->name);<br>
+<br></blockquote><div><br></div><div>This doesn't produce the output you want.  String concatenation happens at compile time and takes precedence over everything else, so this is being interpreted as:<br><br></div><div>
_mesa_glsl_error(&loc, state, is_initializer ? "initializer" : "value of type %s cannot be assigned to variable of type %s", rhs->type->name, lhs_type->name);<br><br></div><div>Adding parenthesis doesn't help because string concatenation only works on string literals.  I believe what you actually want is:<br>
<br>   _mesa_glsl_error(&loc, state,<br>                    "%s of type %s cannot be assigned to "<br>                    "variable of type %s",<br>                    is_initializer ? "initializer" : "value",<br>
                    rhs->type->name, lhs_type->name);<br><br></div><div>With that change, this patch is:<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
<br></div><div>Do you have push access?  I can push the patch for you (with this change) if you'd like. <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

    return NULL;<br>
 }<br>
<br>
@@ -700,10 +706,10 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,<br>
<br>
       if (unlikely(expr->operation == ir_binop_vector_extract)) {<br>
          ir_rvalue *new_rhs =<br>
-            validate_assignment(state, lhs->type, rhs, is_initializer);<br>
+            validate_assignment(state, lhs_loc, lhs->type,<br>
+                                rhs, is_initializer);<br>
<br>
          if (new_rhs == NULL) {<br>
-            _mesa_glsl_error(& lhs_loc, state, "type mismatch");<br>
             return lhs;<br>
          } else {<br>
             rhs = new(ctx) ir_expression(ir_triop_vector_insert,<br>
@@ -752,10 +758,8 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,<br>
    }<br>
<br>
    ir_rvalue *new_rhs =<br>
-      validate_assignment(state, lhs->type, rhs, is_initializer);<br>
-   if (new_rhs == NULL) {<br>
-      _mesa_glsl_error(& lhs_loc, state, "type mismatch");<br>
-   } else {<br>
+      validate_assignment(state, lhs_loc, lhs->type, rhs, is_initializer);<br>
+   if (new_rhs != NULL) {<br>
       rhs = new_rhs;<br>
<br>
       /* If the LHS array was not declared with a size, it takes it size from<br>
@@ -2495,7 +2499,8 @@ process_initializer(ir_variable *var, ast_declaration *decl,<br>
     */<br>
    if (type->qualifier.flags.q.constant<br>
        || type->qualifier.flags.q.uniform) {<br>
-      ir_rvalue *new_rhs = validate_assignment(state, var->type, rhs, true);<br>
+      ir_rvalue *new_rhs = validate_assignment(state, initializer_loc,<br>
+                                               var->type, rhs, true);<br>
       if (new_rhs != NULL) {<br>
         rhs = new_rhs;<br>
<br>
@@ -2524,10 +2529,6 @@ process_initializer(ir_variable *var, ast_declaration *decl,<br>
            var->constant_value = constant_value;<br>
         }<br>
       } else {<br>
-        _mesa_glsl_error(&initializer_loc, state,<br>
-                         "initializer of type %s cannot be assigned to "<br>
-                         "variable of type %s",<br>
-                         rhs->type->name, var->type->name);<br>
         if (var->type->is_numeric()) {<br>
            /* Reduce cascading errors. */<br>
            var->constant_value = ir_constant::zero(state, var->type);<br>
<span class=""><font color="#888888">--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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></div></div>