glsl: Don't allow unnamed interface blocks to redeclare variables.
authorPaul Berry <stereotype441@gmail.com>
Fri, 27 Sep 2013 21:18:09 +0000 (14:18 -0700)
committerPaul Berry <stereotype441@gmail.com>
Thu, 10 Oct 2013 21:27:08 +0000 (14:27 -0700)
Note: some limited amount of redeclaration is actually allowed,
provided the shader is redeclaring the built-in gl_PerVertex interface
block.  Support for this will be added in future patches.

Fixes piglit tests
spec/glsl-1.50/compiler/unnamed-interface-block-elem-conflicts-with-prev-{block-elem,global}.vert.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/ast_to_hir.cpp

index 90401adaafe39bb5865120d8937e0c4789593e5e..c06a2a9c69aa56df819d3e0cb12e7e053250d686 100644 (file)
@@ -4742,6 +4742,9 @@ ast_interface_block::hir(exec_list *instructions,
                                    var_mode);
          var->init_interface_type(block_type);
 
+         if (state->symbols->get_variable(var->name) != NULL)
+            _mesa_glsl_error(&loc, state, "`%s' redeclared", var->name);
+
          /* Propagate the "binding" keyword into this UBO's fields;
           * the UBO declaration itself doesn't get an ir_variable unless it
           * has an instance name.  This is ugly.