summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-06-28 23:38:04 -0700
committerIan Romanick <[email protected]>2010-06-29 11:12:53 -0700
commit18707eba1cd6c07fa8b63d0ba5b26f6433f1ae91 (patch)
treea0d1aea37d1f515e1f385a513c24615c9e4b5a1c /src/glsl/ast_to_hir.cpp
parent153eca98064252be4daad9cc27746f37c245b627 (diff)
glsl2: Check that returned expressions match the function return type.
From my reading of the specification, implicit conversions are not allowed. ATI seems to agree, though nVidia allows it without warning.
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 33eb27533fd..45228649adc 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2151,9 +2151,17 @@ ast_jump_statement::hir(exec_list *instructions,
opt_return_value->hir(instructions, state);
assert(ret != NULL);
- /* FINISHME: Make sure the type of the return value matches the return
- * FINISHME: type of the enclosing function.
- */
+ /* Implicit conversions are not allowed for return values. */
+ 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);
+ }
inst = new(ctx) ir_return(ret);
} else {