From the spec,
Arrays are allowed as arguments, but not as the return type. [...] The
return type can also be a structure if the structure does not contain
an array.
Fixes DEQP shaders.functions.invalid.return_array_in_struct_fragment.
v2: Spec cite wording change
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Matt Turner <mattst88@gmail.com>
"sized", name);
}
+ /* From Section 6.1 (Function Definitions) of the GLSL 1.00 spec:
+ *
+ * "Arrays are allowed as arguments, but not as the return type. [...]
+ * The return type can also be a structure if the structure does not
+ * contain an array."
+ */
+ if (state->language_version == 100 && return_type->contains_array()) {
+ YYLTYPE loc = this->get_location();
+ _mesa_glsl_error(& loc, state,
+ "function `%s' return type contains an array", name);
+ }
+
/* From section 4.1.7 of the GLSL 4.40 spec:
*
* "[Opaque types] can only be declared as function parameters
}
}
+bool
+glsl_type::contains_array() const
+{
+ if (this->is_record() || this->is_interface()) {
+ for (unsigned int i = 0; i < this->length; i++) {
+ if (this->fields.structure[i].type->contains_array())
+ return true;
+ }
+ return false;
+ } else {
+ return this->is_array();
+ }
+}
bool
glsl_type::contains_integer() const
*/
bool contains_sampler() const;
+ /**
+ * Query whether or not type is an array or for struct, interface and
+ * array types, contains an array.
+ */
+ bool contains_array() const;
+
/**
* Get the Mesa texture target index for a sampler type.
*/