[Mesa-dev] [PATCH] glsl: Generate an error for array-of-array declarations
Kenneth Graunke
kenneth at whitecape.org
Mon Oct 24 14:10:40 PDT 2011
On 10/24/2011 12:29 PM, Ian Romanick wrote:
> 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 {
Is there some reason you didn't this down into process_array_type
itself? It may be unnecessary, but it's probably better safe than
sorry, right?
Plus process_array_type has a lovely
/* FINISHME: Reject delcarations of multidimensional arrays. */
that you could swap out for this code.
More information about the mesa-dev
mailing list