diff options
author | Eric Anholt <eric@anholt.net> | 2010-03-30 23:28:20 -1000 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-03-30 23:30:11 -1000 |
commit | aad7c7793788f34e98fb7264dc2219fc73002877 (patch) | |
tree | 718c63f0f31ca75cab13416f1619d3be30936616 | |
parent | ab79d4ec6e7c5639084f71f93857f39239e8b848 (diff) |
Test that a non-void function returns a value.
-rw-r--r-- | ast_to_hir.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index fbadd40318..1f81a94327 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1547,9 +1547,9 @@ ast_jump_statement::hir(exec_list *instructions, if (mode == ast_return) { ir_return *inst; + assert(state->current_function); if (opt_return_value) { - assert(state->current_function); if (state->current_function->return_type->base_type == GLSL_TYPE_VOID) { YYLTYPE loc = this->get_location(); @@ -1570,8 +1570,15 @@ ast_jump_statement::hir(exec_list *instructions, inst = new ir_return(ret); } else { - /* FINISHME: Make sure the enclosing function has a void return type. - */ + if (state->current_function->return_type->base_type != + GLSL_TYPE_VOID) { + YYLTYPE loc = this->get_location(); + + _mesa_glsl_error(& loc, state, + "`return' with no value, in function %s returning " + "non-void", + state->current_function->definition->label); + } inst = new ir_return; } |