summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-06-09 13:29:37 -0700
committerCarl Worth <cworth@cworth.org>2010-06-09 13:29:37 -0700
commit2fb30a2e492e466a7b383e8ca430ba7371b443ee (patch)
tree125ccbb49b159f270ce11e8df4f8488efb944760
parent5ae88af9886b4b7bf486cbc0d10a9bab6456165f (diff)
parent2ab0b13dd9b281b9c68b3d3e2fb01d19564d115e (diff)
Merge remote branch 'kwg/fixes'
-rw-r--r--glcpp-parse.y20
1 files changed, 20 insertions, 0 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y
index b07714eebd..807cf59509 100644
--- a/glcpp-parse.y
+++ b/glcpp-parse.y
@@ -1385,12 +1385,30 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
}
void
+_check_for_reserved_macro_name (const char *identifier)
+{
+ /* 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) {
+ fprintf (stderr, "Error: Macro names starting with \"__\" are reserved.\n");
+ exit(1);
+ }
+ if (strncmp(identifier, "GL_", 3) == 0) {
+ fprintf (stderr, "Error: Macro names starting with \"GL_\" are reserved.\n");
+ exit(1);
+ }
+}
+
+void
_define_object_macro (glcpp_parser_t *parser,
const char *identifier,
token_list_t *replacements)
{
macro_t *macro;
+ _check_for_reserved_macro_name(identifier);
+
macro = xtalloc (parser, macro_t);
macro->is_function = 0;
@@ -1409,6 +1427,8 @@ _define_function_macro (glcpp_parser_t *parser,
{
macro_t *macro;
+ _check_for_reserved_macro_name(identifier);
+
macro = xtalloc (parser, macro_t);
macro->is_function = 1;