glsl: check if implicitly sized arrays match explicitly sized arrays across the same...
authorTimothy Arceri <t_arceri@yahoo.com.au>
Tue, 25 Nov 2014 12:04:23 +0000 (23:04 +1100)
committerTimothy Arceri <t_arceri@yahoo.com.au>
Tue, 23 Dec 2014 08:32:56 +0000 (19:32 +1100)
V2: Improve error message.

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/glsl/linker.cpp

index 44468c78a15e8d02d7a9eec4f43c6891e67ccedc..3f5eac1e26cca3d345b712fc38ca4b150d1bfa01 100644 (file)
@@ -731,8 +731,27 @@ cross_validate_globals(struct gl_shader_program *prog,
                   && ((var->type->length == 0)
                       || (existing->type->length == 0))) {
                  if (var->type->length != 0) {
+                     if (var->type->length <= existing->data.max_array_access) {
+                        linker_error(prog, "%s `%s' declared as type "
+                                     "`%s' but outermost dimension has an index"
+                                     " of `%i'\n",
+                                     mode_string(var),
+                                     var->name, var->type->name,
+                                     existing->data.max_array_access);
+                        return;
+                     }
                     existing->type = var->type;
-                 }
+                 } else if (existing->type->length != 0
+                             && existing->type->length <=
+                                var->data.max_array_access) {
+                     linker_error(prog, "%s `%s' declared as type "
+                                  "`%s' but outermost dimension has an index"
+                                  " of `%i'\n",
+                                  mode_string(var),
+                                  var->name, existing->type->name,
+                                  var->data.max_array_access);
+                     return;
+                  }
                } else if (var->type->is_record()
                   && existing->type->is_record()
                   && existing->type->record_compare(var->type)) {