aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-09-15 10:18:03 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-09-15 10:18:03 +0000
commit5041042620988be8180d56e808f8efe66c56c79b (patch)
tree8e0d501bff80d035729518382d4a712cf34238c5 /gcc/cpplib.c
parent6131fd23f505853e49b7f394b2dcb5de50076ad1 (diff)
downloadgcc-5041042620988be8180d56e808f8efe66c56c79b.zip
gcc-5041042620988be8180d56e808f8efe66c56c79b.tar.gz
gcc-5041042620988be8180d56e808f8efe66c56c79b.tar.bz2
cpphash.h (struct cpp_reader): Remove lexer_pos, directive_pos.
* cpphash.h (struct cpp_reader): Remove lexer_pos, directive_pos. Split mlstring_pos into mls_line and mls_col. * cppinit.c (cpp_create_reader): Initialize line to 1. (cpp_destroy): Free tokenruns. (push_include): Don't update lexer_pos. * cpplex.c (unterminated, parse_string): Update. (lex_token): Don't update lexer_pos, update. * cpplib.c (if_stack): Save line instead of line + col. (start_directive, _cpp_do__Pragma, do_else, do_elif, push_conditional, _cpp_pop_buffer): Update. * cppmacro.c (funlike_invocation_p): Don't save lexer_pos. (_cpp_create_definition): Update. From-SVN: r45627
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 06541ad..e8065f6 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -40,7 +40,7 @@ struct answer
struct if_stack
{
struct if_stack *next;
- cpp_lexer_pos pos; /* line and column where condition started */
+ unsigned int line; /* Line where condition started. */
const cpp_hashnode *mi_cmacro;/* macro name for #ifndef around entire file */
bool skip_elses; /* Can future #else / #elif be skipped? */
bool was_skipping; /* If were skipping on entry. */
@@ -220,8 +220,6 @@ start_directive (pfile)
pfile->state.save_comments = 0;
/* Some handlers need the position of the # for diagnostics. */
- pfile->directive_pos = pfile->lexer_pos;
- pfile->directive_pos.line = pfile->line;
pfile->directive_line = pfile->line;
}
@@ -1154,18 +1152,27 @@ _cpp_do__Pragma (pfile)
cpp_token string;
unsigned char *buffer;
unsigned int len;
- cpp_lexer_pos orig_pos;
- orig_pos = pfile->lexer_pos;
if (get__Pragma_string (pfile, &string))
cpp_error (pfile, "_Pragma takes a parenthesized string literal");
else
{
+ /* Ideally, we'd like
+ token1 _Pragma ("foo") token2
+ to be output as
+ token1
+ # 7 "file.c"
+ #pragma foo
+ # 7 "file.c"
+ token2
+ Getting these correct line markers is a little tricky. */
+
+ unsigned int orig_line = pfile->line;
buffer = destringize (&string.val.str, &len);
run_directive (pfile, T_PRAGMA, (char *) buffer, len);
free ((PTR) buffer);
- pfile->lexer_pos = orig_pos;
- pfile->line = pfile->lexer_pos.line;
+ pfile->line = orig_line;
+ pfile->buffer->saved_flags = BOL;
}
}
@@ -1254,7 +1261,7 @@ do_else (pfile)
if (ifs->type == T_ELSE)
{
cpp_error (pfile, "#else after #else");
- cpp_error_with_line (pfile, ifs->pos.line, ifs->pos.col,
+ cpp_error_with_line (pfile, ifs->line, 0,
"the conditional began here");
}
ifs->type = T_ELSE;
@@ -1289,7 +1296,7 @@ do_elif (pfile)
if (ifs->type == T_ELSE)
{
cpp_error (pfile, "#elif after #else");
- cpp_error_with_line (pfile, ifs->pos.line, ifs->pos.col,
+ cpp_error_with_line (pfile, ifs->line, 0,
"the conditional began here");
}
ifs->type = T_ELIF;
@@ -1355,7 +1362,7 @@ push_conditional (pfile, skip, type, cmacro)
cpp_buffer *buffer = pfile->buffer;
ifs = xobnew (&pfile->buffer_ob, struct if_stack);
- ifs->pos = pfile->directive_pos;
+ ifs->line = pfile->directive_line;
ifs->next = buffer->if_stack;
ifs->skip_elses = pfile->state.skipping || !skip;
ifs->was_skipping = pfile->state.skipping;
@@ -1778,7 +1785,7 @@ _cpp_pop_buffer (pfile)
/* Walk back up the conditional stack till we reach its level at
entry to this file, issuing error messages. */
for (ifs = buffer->if_stack; ifs; ifs = ifs->next)
- cpp_error_with_line (pfile, ifs->pos.line, ifs->pos.col,
+ cpp_error_with_line (pfile, ifs->line, 0,
"unterminated #%s", dtable[ifs->type].name);
/* In case of a missing #endif. */