From 79da0ed2fcb8c88253fe2c9036f17e29c1f319dc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 1 May 2017 16:42:03 -0700 Subject: [PATCH] glsl: Restrict func redeclarations (not just redefinitions) on GLSL 1.00. Fixes DEQP's scoping.invalid.redeclare_function_fragment/vertex. v2: Fix accidental rejection of prototype+decl. Reviewed-by: Samuel Pitoiset (v1) Tested-by: Matt Turner --- 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 33490c831cb..b03476c5763 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -5933,6 +5933,16 @@ ast_function::hir(exec_list *instructions, */ return NULL; } + } else if (state->language_version == 100 && !is_definition) { + /* 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); } } } -- 2.30.2