summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_array_index.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-03-15 15:23:19 -0700
committerIan Romanick <[email protected]>2013-04-08 15:17:05 -0700
commit58d93e324718a5a54f7e12b83d58ff5535be1c9c (patch)
treea2e478d70c27f3854eaa9ad788082374d4793c32 /src/glsl/ast_array_index.cpp
parenta131b87706a6e59be35997d24b2236130aa09689 (diff)
glsl: Don't early-out for error-type inputs
Check the type of the array operand and the index operand before doing other checks. This simplifies the code a bit now (eliminating the error_emitted parameter), and enables some later functional changes. The shader uniform float x[6]; uniform sampler2D s; void main() { gl_Position.x = xx[s + 1]; } still generates (only) the two expected errors: 0:3(33): error: `xx' undeclared 0:3(39): error: Operands to arithmetic operators must be numeric Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/ast_array_index.cpp')
-rw-r--r--src/glsl/ast_array_index.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
index c7ebcbdc6b7..862f64c809b 100644
--- a/src/glsl/ast_array_index.cpp
+++ b/src/glsl/ast_array_index.cpp
@@ -29,15 +29,12 @@ ir_rvalue *
_mesa_ast_array_index_to_hir(void *mem_ctx,
struct _mesa_glsl_parse_state *state,
ir_rvalue *array, ir_rvalue *idx,
- YYLTYPE &loc, YYLTYPE &idx_loc,
- bool error_emitted)
+ YYLTYPE &loc, YYLTYPE &idx_loc)
{
ir_rvalue *result = new(mem_ctx) ir_dereference_array(array, idx);
- if (error_emitted)
- return result;
-
- if (!array->type->is_array()
+ if (!array->type->is_error()
+ && !array->type->is_array()
&& !array->type->is_matrix()
&& !array->type->is_vector()) {
_mesa_glsl_error(& idx_loc, state,
@@ -46,10 +43,12 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
result->type = glsl_type::error_type;
}
- if (!idx->type->is_integer()) {
- _mesa_glsl_error(& idx_loc, state, "array index must be integer type");
- } else if (!idx->type->is_scalar()) {
- _mesa_glsl_error(& idx_loc, state, "array index must be scalar");
+ if (!idx->type->is_error()) {
+ if (!idx->type->is_integer()) {
+ _mesa_glsl_error(& idx_loc, state, "array index must be integer type");
+ } else if (!idx->type->is_scalar()) {
+ _mesa_glsl_error(& idx_loc, state, "array index must be scalar");
+ }
}
/* If the array index is a constant expression and the array has a