[Mesa-dev] [PATCH 3/5 v2] glsl: Restrict func redeclarations (not just redefinitions) on GLSL 1.00.
Eric Anholt
eric at anholt.net
Wed May 3 22:17:06 UTC 2017
Fixes DEQP's scoping.invalid.redeclare_function_fragment/vertex.
v2: Fix accidental rejection of prototype+decl.
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
Thanks for testing! Here's a new version with that fixed. Piglit
series covering this regression and more, to follow.
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 4281fcef2da8..05e8afac0907 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -5712,6 +5712,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.11.0
More information about the mesa-dev
mailing list