summaryrefslogtreecommitdiffstats
path: root/glcpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-06-17 12:41:46 -0700
committerKenneth Graunke <[email protected]>2010-06-21 12:31:03 -0700
commit0774523d1882a087b648e4017e634eb12c12f377 (patch)
tree526fc3f40c220bb5e824c67ef64c508bac26ce27 /glcpp
parent8a132aa08b423765f273e399baea7d68b44cd37d (diff)
glcpp: Add line locations to "Unterminated #if" error message.
Diffstat (limited to 'glcpp')
-rw-r--r--glcpp/glcpp-parse.y15
-rw-r--r--glcpp/glcpp.h1
2 files changed, 10 insertions, 6 deletions
diff --git a/glcpp/glcpp-parse.y b/glcpp/glcpp-parse.y
index 02608644c38..74159c19d81 100644
--- a/glcpp/glcpp-parse.y
+++ b/glcpp/glcpp-parse.y
@@ -123,7 +123,8 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
token_list_t *list);
static void
-_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition);
+_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
+ int condition);
static void
_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
@@ -190,7 +191,7 @@ line:
expanded_line:
IF_EXPANDED expression NEWLINE {
- _glcpp_parser_skip_stack_push_if (parser, $2);
+ _glcpp_parser_skip_stack_push_if (parser, & @1, $2);
}
| ELIF_EXPANDED expression NEWLINE {
_glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2);
@@ -234,12 +235,12 @@ control_line:
| HASH_IFDEF IDENTIFIER NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $2);
talloc_free ($2);
- _glcpp_parser_skip_stack_push_if (parser, macro != NULL);
+ _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
| HASH_IFNDEF IDENTIFIER NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $2);
talloc_free ($2);
- _glcpp_parser_skip_stack_push_if (parser, macro == NULL);
+ _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL);
}
| HASH_ELIF pp_tokens NEWLINE {
token_list_t *expanded;
@@ -923,7 +924,7 @@ void
glcpp_parser_destroy (glcpp_parser_t *parser)
{
if (parser->skip_stack)
- glcpp_print (parser->errors, "Error: Unterminated #if\n");
+ glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
glcpp_lex_destroy (parser->scanner);
hash_table_dtor (parser->defines);
talloc_free (parser);
@@ -1579,7 +1580,8 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
}
static void
-_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition)
+_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
+ int condition)
{
skip_type_t current = SKIP_NO_SKIP;
skip_node_t *node;
@@ -1588,6 +1590,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, int condition)
current = parser->skip_stack->type;
node = xtalloc (parser, skip_node_t);
+ node->loc = *loc;
if (current == SKIP_NO_SKIP) {
if (condition)
diff --git a/glcpp/glcpp.h b/glcpp/glcpp.h
index 45bbff3ad4a..4a2489a96d9 100644
--- a/glcpp/glcpp.h
+++ b/glcpp/glcpp.h
@@ -131,6 +131,7 @@ typedef enum skip_type {
typedef struct skip_node {
skip_type_t type;
+ YYLTYPE loc; /* location of the initial #if/#elif/... */
struct skip_node *next;
} skip_node_t;