diff options
author | Matt Turner <[email protected]> | 2013-05-22 14:57:04 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2013-06-14 11:25:49 -0700 |
commit | fcaa48d9cc8937e0ceb59dfd22ef5b6e6fd1a273 (patch) | |
tree | 44b2c0fc70611acb37cb99ca6ea2024a62ffe782 | |
parent | 1a1b03e6bc904e62f3f644164ace095bbb13836d (diff) |
glsl: Disallow return with a void argument from void functions.
NOTE: This is a candidate for the stable branches.
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 22d0cad5079..4b5f04980a3 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -3393,7 +3393,23 @@ ast_jump_statement::hir(exec_list *instructions, state->current_function->function_name(), state->current_function->return_type->name); } - } + } else if (state->current_function->return_type->base_type == + GLSL_TYPE_VOID) { + YYLTYPE loc = this->get_location(); + + /* The ARB_shading_language_420pack, GLSL ES 3.0, and GLSL 4.20 + * specs add a clarification: + * + * "A void function can only use return without a return argument, even if + * the return argument has void type. Return statements only accept values: + * + * void func1() { } + * void func2() { return func1(); } // illegal return statement" + */ + _mesa_glsl_error(& loc, state, + "void functions can only use `return' without a " + "return argument"); + } inst = new(ctx) ir_return(ret); } else { |