aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppmacro.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-09-14 22:04:46 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-09-14 22:04:46 +0000
commit972938978677f76ef6af494932345945947852ee (patch)
tree4c00cb933362af65600541484760cce6502de1a6 /gcc/cppmacro.c
parent4fb1661fea89a2d72f69dcbe341e253d4b3fffe3 (diff)
downloadgcc-972938978677f76ef6af494932345945947852ee.zip
gcc-972938978677f76ef6af494932345945947852ee.tar.gz
gcc-972938978677f76ef6af494932345945947852ee.tar.bz2
cpperror.c (print_location): Take line and column, for default positioning use the previously lexed token.
* cpperror.c (print_location): Take line and column, for default positioning use the previously lexed token. (_cpp_begin_message): Take line and column. (cpp_ice, cpp_fatal, cpp_error, cpp_error_with_line, cpp_warning, cpp_warning_with_line, cpp_pedwarn, cpp_pedwarn_with_line): Update. * cpphash.h (_cpp_begin_message): Update prototype. * cppinit.c (push_include): Don't set output line. * cpplex.c (_cpp_lex_token): Callback for start of new output lines. * cpplib.c (do_diagnostic, _cpp_pop_buffer): Update. (do_pragma): Kludge for front ends. Don't expand macros at all. * cpplib.h (cpp_lookahead, cpp_token_with_pos, cpp_get_line): Remove. (struct cpp_token): Remove output_line. (struct cpp_callbacks): New member line_change. * cppmacro.c (builtin_macro, paste_all_tokens, replace_args, cpp_get_token): Preserve BOL flag. (cpp_get_line): Remove. (_cpp_backup_tokens): Remove useless abort(). * cppmain.c (cb_line_change): New. (scan_translation_unit): Don't worry about starting new lines here. * scan-decls.c (scan_decls): Update. * c-lex.c (c_lex, init_c_lex): Update. (cb_line_change, src_lineno): New. From-SVN: r45613
Diffstat (limited to 'gcc/cppmacro.c')
-rw-r--r--gcc/cppmacro.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c
index 357d1ba..61abc4a 100644
--- a/gcc/cppmacro.c
+++ b/gcc/cppmacro.c
@@ -135,7 +135,7 @@ builtin_macro (pfile, token)
cpp_reader *pfile;
cpp_token *token;
{
- unsigned char flags = ((token->flags & PREV_WHITE) | AVOID_LPASTE);
+ unsigned char flags = ((token->flags & (PREV_WHITE | BOL)) | AVOID_LPASTE);
cpp_hashnode *node = token->val.node;
switch (node->value.builtin)
@@ -211,21 +211,6 @@ builtin_macro (pfile, token)
token->flags = flags;
}
-/* Used by cpperror.c to obtain the correct line and column to report
- in a diagnostic. */
-const cpp_lexer_pos *
-cpp_get_line (pfile)
- cpp_reader *pfile;
-{
- if (pfile->context->prev == NULL)
- {
- pfile->lexer_pos.line = pfile->cur_token[-1].line;
- pfile->lexer_pos.col = pfile->cur_token[-1].col;
- }
-
- return &pfile->lexer_pos;
-}
-
static void
lock_pools (pfile)
cpp_reader *pfile;
@@ -454,8 +439,8 @@ paste_all_tokens (pfile, lhs)
/* The pasted token has the PREV_WHITE flag of the LHS, is no longer
PASTE_LEFT, and is subject to macro expansion. */
- lhs->flags &= ~(PREV_WHITE | PASTE_LEFT | NO_EXPAND);
- lhs->flags |= orig_flags & (PREV_WHITE | AVOID_LPASTE);
+ lhs->flags &= ~(PREV_WHITE | BOL | PASTE_LEFT | NO_EXPAND);
+ lhs->flags |= orig_flags & (PREV_WHITE | BOL | AVOID_LPASTE);
}
/* Reads the unexpanded tokens of a macro argument into ARG. VAR_ARGS
@@ -818,8 +803,8 @@ replace_args (pfile, macro, args, list)
memcpy (dest, from, count * sizeof (cpp_token));
/* The first token gets PREV_WHITE of the CPP_MACRO_ARG. */
- dest->flags &= ~PREV_WHITE;
- dest->flags |= src->flags & PREV_WHITE;
+ dest->flags &= ~(PREV_WHITE | BOL);
+ dest->flags |= src->flags & (PREV_WHITE | BOL);
dest->flags |= AVOID_LPASTE;
/* The last token gets the PASTE_LEFT of the CPP_MACRO_ARG. */
@@ -984,7 +969,7 @@ cpp_get_token (pfile, token)
else if (enter_macro_context (pfile, node))
{
/* Pass AVOID_LPASTE and our PREV_WHITE to next token. */
- pfile->buffer->saved_flags = ((token->flags & PREV_WHITE)
+ pfile->buffer->saved_flags = ((token->flags & (PREV_WHITE | BOL))
| AVOID_LPASTE);
continue;
}
@@ -1042,8 +1027,6 @@ _cpp_backup_tokens (pfile, count)
pfile->cur_token--;
if (pfile->cur_token == pfile->cur_run->base)
{
- if (pfile->cur_run == NULL)
- abort ();
pfile->cur_run = pfile->cur_run->prev;
pfile->cur_token = pfile->cur_run->limit;
}