From: Chris Forbes Date: Sun, 27 Apr 2014 04:03:55 +0000 (+1200) Subject: glsl: Disallow `precise` redeclarations of vars from outer scopes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0495c6db8406131888cc263aa53ecd3e8b3ea6d;p=mesa.git glsl: Disallow `precise` redeclarations of vars from outer scopes Signed-off-by: Chris Forbes Reviewed-by: Jordan Justen --- diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index a57ce5058e1..e1f95081378 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 "