Module: Mesa
Branch: master
Commit: 79da0ed2fcb8c88253fe2c9036f17e29c1f319dc
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=79da0ed2fcb8c88253fe2c9036f17e29c1f319dc

Author: Eric Anholt <[email protected]>
Date:   Mon May  1 16:42:03 2017 -0700

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 <[email protected]> (v1)
Tested-by: Matt Turner <[email protected]>

---

 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 33490c831c..b03476c576 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);
          }
       }
    }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to