[Mesa-dev] [PATCH 3/4] glsl: Clarify error message about whole-array assignment in GLSL 1.10.
Eric Anholt
eric at anholt.net
Wed Sep 7 12:24:30 PDT 2011
Previously, it would produce:
Failed to compile FS: 0:6(7): error: non-lvalue in assignment
and now it produces:
Failed to compile FS: 0:5(7): error: whole array assignment is not
allowed in GLSL 1.10 or GLSL ES 1.00.
Also, add spec quotation to the two places we have code for array
lvalues in GLSL 1.10.
---
src/glsl/ast_to_hir.cpp | 18 +++++++++++-------
src/glsl/ir.cpp | 6 ++++++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 6ef763c..5ec71e9 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -679,16 +679,20 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
lhs->variable_referenced()->name);
error_emitted = true;
+ } else if (state->language_version <= 110 && lhs->type->is_array()) {
+ /* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
+ *
+ * "Other binary or unary expressions, non-dereferenced
+ * arrays, function names, swizzles with repeated fields,
+ * and constants cannot be l-values."
+ */
+ _mesa_glsl_error(&lhs_loc, state, "whole array assignment is not "
+ "allowed in GLSL 1.10 or GLSL ES 1.00.");
+ error_emitted = true;
} else if (!lhs->is_lvalue()) {
_mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment");
error_emitted = true;
}
-
- if (state->es_shader && lhs->type->is_array()) {
- _mesa_glsl_error(&lhs_loc, state, "whole array assignment is not "
- "allowed in GLSL ES 1.00.");
- error_emitted = true;
- }
}
ir_rvalue *new_rhs =
@@ -2072,7 +2076,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
else
var->depth_layout = ir_depth_layout_none;
- if (var->type->is_array() && state->language_version != 110) {
+ if (var->type->is_array() && state->language_version > 110) {
var->array_lvalue = true;
}
}
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 41ed4f1..9a9e62a 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1105,6 +1105,12 @@ ir_dereference::is_lvalue() const
if ((var == NULL) || var->read_only)
return false;
+ /* From page 32 (page 38 of the PDF) of the GLSL 1.10 spec:
+ *
+ * "Other binary or unary expressions, non-dereferenced arrays,
+ * function names, swizzles with repeated fields, and constants
+ * cannot be l-values."
+ */
if (this->type->is_array() && !var->array_lvalue)
return false;
--
1.7.5.4
More information about the mesa-dev
mailing list