[Mesa-dev] [PATCH 4/6] glsl: Disallow `precise` redeclarations of vars from outer scopes

Chris Forbes chrisf at ijw.co.nz
Sat Apr 26 21:03:55 PDT 2014


Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/glsl/ast_to_hir.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index e7e862b..e71a287 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3108,6 +3108,15 @@ ast_declarator_list::hir(exec_list *instructions,
             _mesa_glsl_error(& loc, state,
                              "undeclared variable `%s' cannot be marked "
                              "precise", decl->identifier);
+         } else if (state->current_function != NULL &&
+                    !state->symbols->name_declared_this_scope(decl->identifier)) {
+            /* Note: we have to check if we're in a function, since
+             * builtins are treated as having come from another scope.
+             */
+            _mesa_glsl_error(& loc, state,
+                             "variable `%s' from an outer scope may not be "
+                             "redeclared `precise' in this scope",
+                             earlier->name);
          } else if (earlier->data.used) {
             _mesa_glsl_error(& loc, state,
                              "variable `%s' may not be redeclared "
-- 
1.9.2



More information about the mesa-dev mailing list