V2: Fix up whitespaces Signed-off-by: Timothy Arceri <t_arc...@yahoo.com.au> --- src/glsl/ast_function.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 2d05d07..0d2cac0 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -752,8 +752,10 @@ process_array_constructor(exec_list *instructions, if (is_unsized_array) { constructor_type = - glsl_type::get_array_instance(constructor_type->element_type(), - parameter_count); + glsl_type::get_array_instance(constructor_type->element_type(), + parameter_count, + constructor_type->dimension_count); + assert(constructor_type != NULL); assert(constructor_type->length == parameter_count); } @@ -782,7 +784,8 @@ process_array_constructor(exec_list *instructions, } } - if (result->type != constructor_type->element_type()) { + if (constructor_type->dimension_count == 1 && + result->type != constructor_type->element_type()) { _mesa_glsl_error(loc, state, "type error in array constructor: " "expected: %s, found %s", constructor_type->element_type()->name, @@ -790,6 +793,40 @@ process_array_constructor(exec_list *instructions, return ir_rvalue::error_value(ctx); } + /* compare arrays of arrays dimensions, element type, and sizes*/ + if (result->type->is_array()) { + + if (result->type->dimension_count != (constructor_type->dimension_count-1)) { + _mesa_glsl_error(loc, state, "type error in array constructor: " + "expected array with: %u dimension(s)," + " found %u dimension(s)", + constructor_type->dimension_count-1, + result->type->dimension_count); + return ir_rvalue::error_value(ctx); + } + + const glsl_type *expected_type = constructor_type->element_type(); + const glsl_type *result_type = result->type; + for (unsigned i=0; i<result->type->dimension_count; i++) { + if (result_type->length != expected_type->length) { + _mesa_glsl_error(loc, state, "type error in array constructor: " + "expected array with size: %u," + " found size %u", + expected_type->length, + result_type->length); + return ir_rvalue::error_value(ctx); + } + expected_type = expected_type->element_type(); + result_type = result_type->element_type(); + } + + if (expected_type != result_type) { + _mesa_glsl_error(loc, state, "type error in array constructor: " + "expected: %s", + expected_type->name); + } + } + /* Attempt to convert the parameter to a constant valued expression. * After doing so, track whether or not all the parameters to the * constructor are trivially constant valued expressions. -- 1.8.3.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev