Test that variable names don't use the reserved gl_ prefix.
authorEric Anholt <eric@anholt.net>
Wed, 31 Mar 2010 18:20:58 +0000 (08:20 -1000)
committerEric Anholt <eric@anholt.net>
Wed, 31 Mar 2010 19:17:35 +0000 (09:17 -1000)
Fixes identifier2.frag.

ast_to_hir.cpp

index f66c02980852f7766b5243ce096c9319a567f882..708656a6fce085e2e4f2ca1c5119fc9081fb29db 100644 (file)
@@ -1177,6 +1177,21 @@ ast_declarator_list::hir(exec_list *instructions,
         continue;
       }
 
+      /* 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(decl->identifier, "gl_", 3) == 0) {
+        /* FINISHME: This should only trigger if we're not redefining
+         * FINISHME: a builtin (to add a qualifier, for example).
+         */
+        _mesa_glsl_error(& loc, state,
+                         "identifier `%s' uses reserved `gl_' prefix",
+                         decl->identifier);
+      }
+
       instructions->push_tail(var);
 
       if (this->type->qualifier.attribute