aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-01-23 16:30:09 +0000
committermarha <marha@users.sourceforge.net>2011-01-23 16:30:09 +0000
commit8cd59857a99c534c560f58c931f5c2466d4c1f9b (patch)
treefd9f3d3f8c557611c1fc509cb947e826b3da1999 /mesalib/src/glsl/ast_to_hir.cpp
parentb8ffa56f8bda74a402eae0c89aadfda7b7db507f (diff)
downloadvcxsrv-8cd59857a99c534c560f58c931f5c2466d4c1f9b.tar.gz
vcxsrv-8cd59857a99c534c560f58c931f5c2466d4c1f9b.tar.bz2
vcxsrv-8cd59857a99c534c560f58c931f5c2466d4c1f9b.zip
mesalib git update 23/1/2011
Diffstat (limited to 'mesalib/src/glsl/ast_to_hir.cpp')
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 85a53d2a9..d2a499868 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -3010,27 +3010,26 @@ ast_jump_statement::hir(exec_list *instructions,
assert(state->current_function);
if (opt_return_value) {
- if (state->current_function->return_type->base_type ==
- GLSL_TYPE_VOID) {
- YYLTYPE loc = this->get_location();
-
- _mesa_glsl_error(& loc, state,
- "`return` with a value, in function `%s' "
- "returning void",
- state->current_function->function_name());
- }
-
ir_rvalue *const ret = opt_return_value->hir(instructions, state);
- assert(ret != NULL);
+
+ /* The value of the return type can be NULL if the shader says
+ * 'return foo();' and foo() is a function that returns void.
+ *
+ * NOTE: The GLSL spec doesn't say that this is an error. The type
+ * of the return value is void. If the return type of the function is
+ * also void, then this should compile without error. Seriously.
+ */
+ const glsl_type *const ret_type =
+ (ret == NULL) ? glsl_type::void_type : ret->type;
/* Implicit conversions are not allowed for return values. */
- if (state->current_function->return_type != ret->type) {
+ 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,
+ ret_type->name,
state->current_function->function_name(),
state->current_function->return_type->name);
}