glsl: Fix function return typechecking
authorOscar Blumberg <carnaval@12-10e.me>
Mon, 11 Feb 2019 16:46:20 +0000 (17:46 +0100)
committerTapani Pälli <tapani.palli@intel.com>
Mon, 25 Feb 2019 06:49:06 +0000 (08:49 +0200)
apply_implicit_conversion only converts and check base types but we
need actual type equality for function returns, otherwise you can
return a vec2 from a function declared as returning a float.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/compiler/glsl/ast_to_hir.cpp

index f68ed46435bc87f9b30de9b8147dad6f504206f6..92a9650cc05554cf8b162754128501df8bd8a836 100644 (file)
@@ -6249,7 +6249,8 @@ ast_jump_statement::hir(exec_list *instructions,
 
             if (state->has_420pack()) {
                if (!apply_implicit_conversion(state->current_function->return_type,
-                                              ret, state)) {
+                                              ret, state)
+                   || (ret->type != state->current_function->return_type)) {
                   _mesa_glsl_error(& loc, state,
                                    "could not implicitly convert return value "
                                    "to %s, in function `%s'",