summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-06-17 12:21:53 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-06-21 12:31:03 -0700
commitdcdf62f1c64f41ca2d1da4cf59e1b6f40542a934 (patch)
treeea26aea5d092e49996143bef210bba0ad5768e0b
parentca9e5fce25a8cffea04be0c1b9590265764c2af6 (diff)
glcpp: Add line locations to "reserved name" error messages.
-rw-r--r--glcpp/glcpp-parse.y21
1 files changed, 13 insertions, 8 deletions
diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y
index 0444b0c..b1669fa 100644
--- a/glcpp/glcpp-parse.y
+++ b/glcpp/glcpp-parse.y
@@ -38,11 +38,13 @@ yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
static void
_define_object_macro (glcpp_parser_t *parser,
+ YYLTYPE *loc,
const char *macro,
token_list_t *replacements);
static void
_define_function_macro (glcpp_parser_t *parser,
+ YYLTYPE *loc,
const char *macro,
string_list_t *parameters,
token_list_t *replacements);
@@ -197,13 +199,13 @@ expanded_line:
control_line:
HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE {
- _define_object_macro (parser, $2, $3);
+ _define_object_macro (parser, & @2, $2, $3);
}
| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE {
- _define_function_macro (parser, $2, NULL, $5);
+ _define_function_macro (parser, & @2, $2, NULL, $5);
}
| HASH_DEFINE_FUNC IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE {
- _define_function_macro (parser, $2, $4, $6);
+ _define_function_macro (parser, & @2, $2, $4, $6);
}
| HASH_UNDEF IDENTIFIER NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $2);
@@ -1413,29 +1415,31 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
}
void
-_check_for_reserved_macro_name (glcpp_parser_t *parser, const char *identifier)
+_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
+ 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) {
- glcpp_print (parser->errors, "Error: Macro names starting with \"__\" are reserved.\n");
+ glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
exit(1);
}
if (strncmp(identifier, "GL_", 3) == 0) {
- glcpp_print (parser->errors, "Error: Macro names starting with \"GL_\" are reserved.\n");
+ glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
exit(1);
}
}
void
_define_object_macro (glcpp_parser_t *parser,
+ YYLTYPE *loc,
const char *identifier,
token_list_t *replacements)
{
macro_t *macro;
- _check_for_reserved_macro_name(parser, identifier);
+ _check_for_reserved_macro_name(parser, loc, identifier);
macro = xtalloc (parser, macro_t);
@@ -1449,13 +1453,14 @@ _define_object_macro (glcpp_parser_t *parser,
void
_define_function_macro (glcpp_parser_t *parser,
+ YYLTYPE *loc,
const char *identifier,
string_list_t *parameters,
token_list_t *replacements)
{
macro_t *macro;
- _check_for_reserved_macro_name(parser, identifier);
+ _check_for_reserved_macro_name(parser, loc, identifier);
macro = xtalloc (parser, macro_t);