summaryrefslogtreecommitdiff
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-08-20 02:14:35 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-08-20 02:46:05 -0700
commitedd180f03216d2fcb2771aeea34e7015fb2b83c3 (patch)
treedb1d35300a7fd27e1a5cbb0971239aacd47e7b97 /src/glsl/ast_to_hir.cpp
parent826a39cb14244820e8539a2328bb52447348f184 (diff)
ast_to_hir: Reject function names that start with "gl_".
Fixes piglit test redeclaration-03.vert.
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 0d2c471f45..4188348626 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2099,6 +2099,18 @@ ast_function::hir(exec_list *instructions,
const char *const name = identifier;
+ /* From page 15 (page 21 of the PDF) of the GLSL 1.10 spec,
+ *
+ * "Identifiers starting with "gl_" are reserved for use by
+ * OpenGL, and may not be declared in a shader as either a
+ * variable or a function."
+ */
+ if (strncmp(name, "gl_", 3) == 0) {
+ YYLTYPE loc = this->get_location();
+ _mesa_glsl_error(&loc, state,
+ "identifier `%s' uses reserved `gl_' prefix", name);
+ }
+
/* Convert the list of function parameters to HIR now so that they can be
* used below to compare this function's signature with previously seen
* signatures for functions with the same name.