glsl: Restrict func redeclarations (not just redefinitions) on GLSL 1.00.
authorEric Anholt <eric@anholt.net>
Mon, 1 May 2017 23:42:03 +0000 (16:42 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 8 May 2017 19:15:49 +0000 (12:15 -0700)
Fixes DEQP's scoping.invalid.redeclare_function_fragment/vertex.

v2: Fix accidental rejection of prototype+decl.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> (v1)
Tested-by: Matt Turner <mattst88@gmail.com>
src/compiler/glsl/ast_to_hir.cpp

index 33490c831cb503a0faabd5311d3c1bb7b9c78c33..b03476c576396e3bf3fe6e565e3accac7b6feabd 100644 (file)
@@ -5933,6 +5933,16 @@ ast_function::hir(exec_list *instructions,
                 */
                return NULL;
             }
+         } else if (state->language_version == 100 && !is_definition) {
+            /* From the GLSL 1.00 spec, section 4.2.7:
+             *
+             *     "A particular variable, structure or function declaration
+             *      may occur at most once within a scope with the exception
+             *      that a single function prototype plus the corresponding
+             *      function definition are allowed."
+             */
+            YYLTYPE loc = this->get_location();
+            _mesa_glsl_error(&loc, state, "function `%s' redeclared", name);
          }
       }
    }