[Mesa-dev] [PATCH 3/5] glsl: Restrict func redeclarations (not just redefinitions) on GLSL 1.00.

Eric Anholt eric at anholt.net
Tue May 2 17:36:08 UTC 2017


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);
          }
       }
    }
-- 
2.11.0



More information about the mesa-dev mailing list