[Mesa-dev] [PATCH 3/5] glsl: Restrict func redeclarations (not just redefinitions) on GLSL 1.00.
Matt Turner
mattst88 at gmail.com
Tue May 2 22:38:20 UTC 2017
On Tue, May 2, 2017 at 10:36 AM, Eric Anholt <eric at anholt.net> wrote:
> Fixes DEQP's scoping.invalid.redeclare_function_fragment/vertex.
> ---
> src/compiler/glsl/ast_to_hir.cpp | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
> index 9e02529dffb9..58088cec0d3a 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -5711,6 +5711,16 @@ ast_function::hir(exec_list *instructions,
> */
> return NULL;
> }
> + } else if (state->language_version == 100) {
> + /* From the GLSL 1.00 spec, section 4.2.7:
> + *
> + * "A particular variable, structure or function declaration
> + * may occur at most once within a scope with the exception
> + * that a single function prototype plus the corresponding
> + * function definition are allowed."
> + */
> + YYLTYPE loc = this->get_location();
> + _mesa_glsl_error(&loc, state, "function `%s' redeclared", name);
This patch causes
dEQP-GLES2.functional.shaders.functions.declarations.void_vs_no_void_vertex
(among others) to fail:
"""
precision mediump float;
attribute highp vec4 dEQP_Position;
attribute float in0;
varying float out0;
float func ();
void main()
{
out0 = func() * in0;
gl_Position = dEQP_Position;
}
float func (void)
{
return -1.0;
}
"""
error: function `func' redeclared
>From a cursory glance, all of the failures seem to be from this same problem.
More information about the mesa-dev
mailing list