Mesa (master): Report that no function found if signature lookup is empty

Ian Romanick idr at kemper.freedesktop.org
Fri Dec 20 17:04:39 UTC 2013


Module: Mesa
Branch: master
Commit: 3b1195f8a631d3425a418f846a6b9e0fa570c028
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3b1195f8a631d3425a418f846a6b9e0fa570c028

Author: Kevin Rogovin <kevin.rogovin at intel.com>
Date:   Mon Dec  9 11:18:26 2013 +0200

Report that no function found if signature lookup is empty

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.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/glsl/ast_function.cpp |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 605ab8c..e4c0fd1 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->symbols->get_function(name) == NULL
+      && (!state->uses_builtin_functions
+          || sh->symbols->get_function(name) == NULL)) {
+      _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);
 
-   if (state->uses_builtin_functions) {
-      gl_shader *sh = _mesa_glsl_get_builtin_function_shader();
-      print_function_prototypes(state, loc, sh->symbols->get_function(name));
+      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-commit mailing list