[Mesa-dev] [PATCH 1/2] glsl: Emit warning if a var declaration shadows one at a higher scope.

Iago Toral Quiroga itoral at igalia.com
Fri Apr 11 03:52:03 PDT 2014


---
 src/glsl/ast_to_hir.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 8d55ee3..b70b628 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3180,10 +3180,6 @@ ast_declarator_list::hir(exec_list *instructions,
       const struct glsl_type *var_type;
       ir_variable *var;
 
-      /* FINISHME: Emit a warning if a variable declaration shadows a
-       * FINISHME: declaration at a higher scope.
-       */
-
       if ((decl_type == NULL) || decl_type->is_void()) {
 	 if (type_name != NULL) {
 	    _mesa_glsl_error(& loc, state,
@@ -3197,6 +3193,12 @@ ast_declarator_list::hir(exec_list *instructions,
 	 continue;
       }
 
+      if (state->symbols->get_variable(decl->identifier)) {
+         _mesa_glsl_warning(& loc, state,
+                            "Overriding previous definition of '%s'\n",
+                            decl->identifier);
+      }
+
       var_type = process_array_type(&loc, decl_type, decl->array_specifier,
                                     state);
 
-- 
1.8.3.2



More information about the mesa-dev mailing list