glsl: Disallow `precise` redeclarations of vars from outer scopes
authorChris Forbes <chrisf@ijw.co.nz>
Sun, 27 Apr 2014 04:03:55 +0000 (16:03 +1200)
committerChris Forbes <chrisf@ijw.co.nz>
Wed, 4 Jun 2014 06:56:08 +0000 (18:56 +1200)
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/glsl/ast_to_hir.cpp

index a57ce50..e1f9508 100644 (file)
@@ -3187,6 +3187,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 "