glcpp: Disallow "defined" as a macro name.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 18 Feb 2016 01:15:23 +0000 (17:15 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 18 Feb 2016 21:38:50 +0000 (13:38 -0800)
Both GCC and Clang disallow this, and glslang has recently started
disallowing it as well.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94188
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/glsl/glcpp/glcpp-parse.y

index 43a1aa94aff6b9cfb8c3c57d6ea6b05a3b1c9477..70951a022c3236a3d6a09248df2c423cdfb1711f 100644 (file)
@@ -2096,6 +2096,9 @@ _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
        if (strncmp(identifier, "GL_", 3) == 0) {
                glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
        }
+       if (strcmp(identifier, "defined") == 0) {
+               glcpp_error (loc, parser, "\"defined\" cannot be used as a macro name");
+       }
 }
 
 static int