glsl/glcpp: Do not allow undefining the built-in macros
authorAnuj Phogat <anuj.phogat@gmail.com>
Fri, 6 Jun 2014 23:56:58 +0000 (16:56 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 9 Jul 2014 19:05:13 +0000 (12:05 -0700)
Fixes piglit tests in spec/glsl-es-3.00/compile:
undef-__FILE__.vert
undef-GL_ES.vert
undef-__LINE__.vert
undef-__VERSION__.vert

Also, fixes Khronos GLES3 CTS tests:
undefine_invalid_object_1_vertex
undefine_invalid_object_1_fragment
undefine_invalid_object_2_vertex
undefine_invalid_object_2_fragment

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
src/glsl/glcpp/glcpp-parse.y

index ccf8105597bab0e7eb6a6d4cb20f4fa02b54f368..9d8b5bbb0b67eae382076ebc0452a088a9bd925f 100644 (file)
@@ -260,6 +260,12 @@ control_line:
 |      HASH_UNDEF {
                glcpp_parser_resolve_implicit_version(parser);
        } IDENTIFIER NEWLINE {
+               if (strcmp("__LINE__", $3) == 0
+                   || strcmp("__FILE__", $3) == 0
+                   || strcmp("__VERSION__", $3) == 0)
+                       glcpp_error(& @1, parser, "Built-in (pre-defined)"
+                                   " macro names can not be undefined.");
+
                macro_t *macro = hash_table_find (parser->defines, $3);
                if (macro) {
                        hash_table_remove (parser->defines, $3);