[Mesa-dev] [PATCH] Report that no function found if signature lookup is empty

Ian Romanick idr at freedesktop.org
Fri Dec 20 10:27:24 PST 2013


On 12/09/2013 01:18 AM, Kevin Rogovin wrote:
> Enhancement: if no function signature is found for a function
> name, report that the function is not found instead of printing
> an empty list of candidates.

I made the minor changes that I mention below and pushed it with my R-b.

> ---
>  src/glsl/ast_function.cpp | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
> index 9dc5427..ec4339c 100644
> --- a/src/glsl/ast_function.cpp
> +++ b/src/glsl/ast_function.cpp
> @@ -450,17 +450,24 @@ no_matching_function_error(const char *name,
>  			   exec_list *actual_parameters,
>  			   _mesa_glsl_parse_state *state)
>  {
> -   char *str = prototype_string(NULL, name, actual_parameters);
> -   _mesa_glsl_error(loc, state,
> -                    "no matching function for call to `%s'; candidates are:",
> -                    str);
> -   ralloc_free(str);
> +   gl_shader *sh = _mesa_glsl_get_builtin_function_shader();
>  
> -   print_function_prototypes(state, loc, state->symbols->get_function(name));
> -
> -   if (state->uses_builtin_functions) {
> -      gl_shader *sh = _mesa_glsl_get_builtin_function_shader();
> -      print_function_prototypes(state, loc, sh->symbols->get_function(name));
> +   if(NULL == state->symbols->get_function(name)
        ^ space here

I understand that there are reasons people like the 'NULL == foo' form,
it is not used anywhere else in Mesa.  I'd prefer to have the code
remain consistent by using the 'foo == NULL' form.  If someone mistypes
'foo = NULL', GCC will issue a warning.

> +      && (!state->uses_builtin_functions 
> +          || NULL == sh->symbols->get_function(name)) ) {
                                     delete this space  ^

> +      _mesa_glsl_error(loc, state, "no function with name '%s'", name);
> +   } else {
> +      char *str = prototype_string(NULL, name, actual_parameters);
> +      _mesa_glsl_error(loc, state,
> +                       "no matching function for call to `%s'; candidates are:",
> +                       str);
> +      ralloc_free(str);
> +      
> +      print_function_prototypes(state, loc, state->symbols->get_function(name));
> +      
> +      if (state->uses_builtin_functions) {         
> +         print_function_prototypes(state, loc, sh->symbols->get_function(name));
> +      }
>     }
>  }
>  
> 



More information about the mesa-dev mailing list