[Mesa-dev] [PATCH] glsl: Generate an error for array-of-array declarations

Ian Romanick idr at freedesktop.org
Mon Oct 24 12:29:08 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

Other parts of the code already caught things like 'float x[4][2]'.
However, nothing caught 'float [4] x[2]'.

Fixes piglit test array-multidimensional-new-syntax.vert.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/ast_to_hir.cpp |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 70afb67..b08b443 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2476,6 +2476,18 @@ ast_declarator_list::hir(exec_list *instructions,
       }
 
       if (decl->is_array) {
+	 /* From page 19 (page 25) of the GLSL 1.20 spec:
+	  *
+	  *     "Only one-dimensional arrays may be declared."
+	  */
+	 if (decl_type->is_array()) {
+	    _mesa_glsl_error(& loc, state,
+			     "invalid array of `%s' in declaration of `%s'",
+			     decl_type->name,
+			     decl->identifier);
+	    continue;
+	 }
+
 	 var_type = process_array_type(&loc, decl_type, decl->array_size,
 				       state);
       } else {
-- 
1.7.6.4



More information about the mesa-dev mailing list