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

Submitted by Iago Toral on April 11, 2014, 10:52 a.m.

Details

Message ID 1397213524-5412-2-git-send-email-itoral@igalia.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Iago Toral April 11, 2014, 10:52 a.m.
---
 src/glsl/ast_to_hir.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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);