Track max accessed array element, reject additional out-of-bounds accesses

For unsized arrays, we can't flag out-of-bounds accesses until the
array is redeclared with a size.  Track the maximum accessed element
and generate an error if the declaration specifies a size that would
cause that access to be out-of-bounds.

This causes the following tests to pass:

    glslparsertest/shaders/array10.frag
This commit is contained in:
Ian Romanick
2010-04-01 18:31:11 -07:00
parent 27e3cf8c0d
commit b8a21cc6df
3 changed files with 43 additions and 9 deletions

2
ir.cpp
View File

@@ -246,7 +246,7 @@ ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
ir_variable::ir_variable(const struct glsl_type *type, const char *name)
: ir_instruction(), read_only(false), centroid(false), invariant(false),
: max_array_access(0), read_only(false), centroid(false), invariant(false),
mode(ir_var_auto), interpolation(ir_var_smooth)
{
this->type = type;