summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/glsl/ast_to_hir.cpp10
-rw-r--r--src/glsl/glsl_parser_extras.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 5a13b74c037..c5df0b0fd0c 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2097,6 +2097,7 @@ ast_function_definition::hir(exec_list *instructions,
assert(state->current_function == NULL);
state->current_function = signature;
+ state->found_return = false;
/* Duplicate parameters declared in the prototype as concrete variables.
* Add these to the symbol table.
@@ -2128,6 +2129,14 @@ ast_function_definition::hir(exec_list *instructions,
assert(state->current_function == signature);
state->current_function = NULL;
+ if (!signature->return_type->is_void() && !state->found_return) {
+ YYLTYPE loc = this->get_location();
+ _mesa_glsl_error(& loc, state, "function `%s' has non-void return type "
+ "%s, but no return statement",
+ signature->function_name(),
+ signature->return_type->name);
+ }
+
/* Function definitions do not have r-values.
*/
return NULL;
@@ -2186,6 +2195,7 @@ ast_jump_statement::hir(exec_list *instructions,
inst = new(ctx) ir_return;
}
+ state->found_return = true;
instructions->push_tail(inst);
break;
}
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index cfe02e3b0c1..726bafa7e4b 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -51,6 +51,9 @@ struct _mesa_glsl_parse_state {
*/
class ir_function_signature *current_function;
+ /** Have we found a return statement in this function? */
+ bool found_return;
+
/** Was there an error during compilation? */
bool error;