Mesa (master): glsl: Cleanly fail when a function has an unknown return type.

Eric Anholt anholt at kemper.freedesktop.org
Mon Aug 23 20:31:43 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Aug 23 13:26:52 2010 -0700

glsl: Cleanly fail when a function has an unknown return type.

Bug #29608.

---

 src/glsl/ast_to_hir.cpp |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 8e4c329..7ac24b0 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2138,7 +2138,13 @@ ast_function::hir(exec_list *instructions,
    const glsl_type *return_type =
       this->return_type->specifier->glsl_type(& return_type_name, state);
 
-   assert(return_type != NULL);
+   if (!return_type) {
+      YYLTYPE loc = this->get_location();
+      _mesa_glsl_error(&loc, state,
+		       "function `%s' has undeclared return type `%s'",
+		       name, return_type_name);
+      return_type = glsl_type::error_type;
+   }
 
    /* From page 56 (page 62 of the PDF) of the GLSL 1.30 spec:
     * "No qualifier is allowed on the return type of a function."




More information about the mesa-commit mailing list