Mesa (master): glsl: Disallow `precise` redeclarations of vars from outer scopes
Chris Forbes
chrisf at kemper.freedesktop.org
Wed Jun 4 07:09:32 UTC 2014
Module: Mesa
Branch: master
Commit: d0495c6db8406131888cc263aa53ecd3e8b3ea6d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d0495c6db8406131888cc263aa53ecd3e8b3ea6d
Author: Chris Forbes <chrisf at ijw.co.nz>
Date: Sun Apr 27 16:03:55 2014 +1200
glsl: Disallow `precise` redeclarations of vars from outer scopes
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
---
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 a57ce50..e1f9508 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -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 "
More information about the mesa-commit
mailing list