[Mesa-dev] [PATCH 2/2] glsl/ast: don't accept function calls as constructors.

Iago Toral itoral at igalia.com
Tue May 3 14:29:31 UTC 2016


On Tue, 2016-05-03 at 14:39 +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> This fixes a crash in
> GL43-CTS.shader_subroutine.subroutines_not_allowed_as_variables_constructors_and_argument_or_return_types
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/compiler/glsl/ast_function.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
> index 37fb3e79..fe0df15 100644
> --- a/src/compiler/glsl/ast_function.cpp
> +++ b/src/compiler/glsl/ast_function.cpp
> @@ -2031,7 +2031,10 @@ ast_function_expression::hir(exec_list *instructions,
>        process_parameters(instructions, &actual_parameters, &this->expressions,
>  			 state);
>  
> -      if (id->oper == ast_array_index) {
> +      if (id->oper == ast_function_call) {
> +         _mesa_glsl_error(& loc, state, "function call cannot be used as a constructor\n");
> +	 return ir_rvalue::error_value(ctx);
> +      } else if (id->oper == ast_array_index) {
>           array_idx = generate_array_index(ctx, instructions, state, loc,
>                                            id->subexpressions[0],
>                                            id->subexpressions[1], &func_name,

Doesn't this affect normal function calls? I did a quick test and
noticed that here we see id->opr == ast_identifier for a function call
but I am not sure if that is always the case...

Iago



More information about the mesa-dev mailing list