glsl: Require function return type arrays be explicitly sized
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 9 Aug 2013 00:40:38 +0000 (17:40 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 14 Aug 2013 00:53:33 +0000 (17:53 -0700)
Fixes piglit array-function-return-unsized.vert.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "9.2" <mesa-stable@lists.freedesktop.org>
src/glsl/ast_to_hir.cpp

index 325cb064153ec1757096fc06a7b39d08c567997a..49804b751e85122c33e9cbcbd47b98fe011edbe0 100644 (file)
@@ -3477,6 +3477,18 @@ ast_function::hir(exec_list *instructions,
                       "function `%s' return type has qualifiers", name);
    }
 
+   /* Section 6.1 (Function Definitions) of the GLSL 1.20 spec says:
+    *
+    *     "Arrays are allowed as arguments and as the return type. In both
+    *     cases, the array must be explicitly sized."
+    */
+   if (return_type->is_array() && return_type->length == 0) {
+      YYLTYPE loc = this->get_location();
+      _mesa_glsl_error(& loc, state,
+                      "function `%s' return type array must be explicitly "
+                      "sized", name);
+   }
+
    /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
     *
     *    "[Sampler types] can only be declared as function parameters