From 445690db19eeb7b9766d25627d9b05cc6c49616c Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Mon, 15 Nov 2010 17:55:35 -0800 Subject: [PATCH] bug-31576: Fix bug, and consequently break the language --- src/glsl/ast_to_hir.cpp | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 4540e98..75497f1 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2640,16 +2640,20 @@ ast_jump_statement::hir(exec_list *instructions, opt_return_value->hir(instructions, state); assert(ret != NULL); - /* Implicit conversions are not allowed for return values. */ + // If necessary, attempt to implicitly convert return value. if (state->current_function->return_type != ret->type) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, - "`return' with wrong type %s, in function `%s' " - "returning %s", - ret->type->name, - state->current_function->function_name(), - state->current_function->return_type->name); + bool conversion_success = apply_implicit_conversion( + state->current_function->return_type, ret, state); + if (!conversion_success) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(& loc, state, + "`return' with wrong type %s, in function `%s' " + "returning %s", + ret->type->name, + state->current_function->function_name(), + state->current_function->return_type->name); + + } } inst = new(ctx) ir_return(ret); -- 1.7.1