glcpp: Raise error if defining any macro containing two consecutive underscores
authorCarl Worth <cworth@cworth.org>
Fri, 30 Sep 2011 04:44:52 +0000 (21:44 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 30 Sep 2011 18:44:16 +0000 (11:44 -0700)
The specification reserves any macro name containing two consecutive
underscores, (anywhere within the name). Previously, we only raised
this error for macro names that started with two underscores.

Fix the implementation to check for two underscores anywhere, and also
update the corresponding 086-reserved-macro-names test.

This also fixes the following two piglit tests:

spec/glsl-1.30/preprocessor/reserved/double-underscore-02.frag
spec/glsl-1.30/preprocessor/reserved/double-underscore-03.frag

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Carl Worth <cworth@cworth.org>
src/glsl/glcpp/glcpp-parse.y
src/glsl/glcpp/tests/086-reserved-macro-names.c
src/glsl/glcpp/tests/086-reserved-macro-names.c.expected

index ff9fa7a49b44d7a74cbe60b97e305a81bbf162be..17941a9be8a6b679a40e45bac6b5d2fc7971d184 100644 (file)
@@ -1663,8 +1663,8 @@ _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
        /* According to the GLSL specification, macro names starting with "__"
         * or "GL_" are reserved for future use.  So, don't allow them.
         */
-       if (strncmp(identifier, "__", 2) == 0) {
-               glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
+       if (strstr(identifier, "__")) {
+               glcpp_error (loc, parser, "Macro names containing \"__\" are reserved.\n");
        }
        if (strncmp(identifier, "GL_", 3) == 0) {
                glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
index fd0c29f0c47d1b865372bb83195675c7c91ddb9d..a6b7201f95ddd96f6d6ba869bbb62733c592d57a 100644 (file)
@@ -1,2 +1,3 @@
 #define __BAD reserved
 #define GL_ALSO_BAD() also reserved
+#define THIS__TOO__IS__BAD reserved
index 6a9df682685b3258cb25643b2ad52c93cae20837..d8aa9f0a64848cfe195693d490aff7c79aabebf6 100644 (file)
@@ -1,7 +1,10 @@
-0:1(10): preprocessor error: Macro names starting with "__" are reserved.
+0:1(10): preprocessor error: Macro names containing "__" are reserved.
 
 0:2(9): preprocessor error: Macro names starting with "GL_" are reserved.
 
+0:3(9): preprocessor error: Macro names containing "__" are reserved.
+
+