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
This commit is contained in:
parent
6131fd23f5
commit
5041042620
6 changed files with 60 additions and 38 deletions
|
@ -1,3 +1,18 @@
|
|||
2001-09-15 Neil Booth <neil@daikokuya.demon.co.uk>
|
||||
|
||||
* 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.
|
||||
|
||||
2001-09-15 Eric Christopher <echristo@redhat.com>
|
||||
|
||||
* config/mips/abi64.h: Add support for MEABI.
|
||||
|
|
|
@ -242,9 +242,7 @@ struct cpp_reader
|
|||
const struct line_map *map;
|
||||
unsigned int line;
|
||||
|
||||
/* The position of the last lexed token and last lexed directive. */
|
||||
cpp_lexer_pos lexer_pos;
|
||||
cpp_lexer_pos directive_pos;
|
||||
/* The line of the '#' of the current directive. */
|
||||
unsigned int directive_line;
|
||||
|
||||
/* Memory pools. */
|
||||
|
@ -278,7 +276,8 @@ struct cpp_reader
|
|||
|
||||
/* Line and column where a newline was first seen in a string
|
||||
constant (multi-line strings). */
|
||||
cpp_lexer_pos mlstring_pos;
|
||||
unsigned int mls_line;
|
||||
unsigned int mls_col;
|
||||
|
||||
/* Buffer to hold macro definition string. */
|
||||
unsigned char *macro_buffer;
|
||||
|
|
|
@ -502,8 +502,10 @@ cpp_create_reader (table, lang)
|
|||
be needed. */
|
||||
pfile->deps = deps_init ();
|
||||
|
||||
/* Initialise the line map. */
|
||||
/* Initialise the line map. Start at logical line 1, so we can use
|
||||
a line number of zero for special states. */
|
||||
init_line_maps (&pfile->line_maps);
|
||||
pfile->line = 1;
|
||||
|
||||
/* Initialize lexer state. */
|
||||
pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
|
||||
|
@ -564,6 +566,7 @@ cpp_destroy (pfile)
|
|||
int result;
|
||||
struct search_path *dir, *dirn;
|
||||
cpp_context *context, *contextn;
|
||||
tokenrun *run, *runn;
|
||||
|
||||
while (CPP_BUFFER (pfile) != NULL)
|
||||
_cpp_pop_buffer (pfile);
|
||||
|
@ -585,6 +588,14 @@ cpp_destroy (pfile)
|
|||
_cpp_free_pool (&pfile->macro_pool);
|
||||
_cpp_free_pool (&pfile->argument_pool);
|
||||
|
||||
for (run = &pfile->base_run; run; run = runn)
|
||||
{
|
||||
runn = run->next;
|
||||
free (run->base);
|
||||
if (run != &pfile->base_run)
|
||||
free (run);
|
||||
}
|
||||
|
||||
for (dir = CPP_OPTION (pfile, quote_include); dir; dir = dirn)
|
||||
{
|
||||
dirn = dir->next;
|
||||
|
@ -886,7 +897,7 @@ push_include (pfile, p)
|
|||
header.val.str.text = (const unsigned char *) p->arg;
|
||||
header.val.str.len = strlen (p->arg);
|
||||
/* Make the command line directive take up a line. */
|
||||
pfile->lexer_pos.line = ++pfile->line;
|
||||
pfile->line++;
|
||||
|
||||
return _cpp_execute_include (pfile, &header, IT_CMDLINE);
|
||||
}
|
||||
|
|
21
gcc/cpplex.c
21
gcc/cpplex.c
|
@ -656,13 +656,11 @@ unterminated (pfile, term)
|
|||
{
|
||||
cpp_error (pfile, "missing terminating %c character", term);
|
||||
|
||||
if (term == '\"' && pfile->mlstring_pos.line
|
||||
&& pfile->mlstring_pos.line != pfile->lexer_pos.line)
|
||||
if (term == '\"' && pfile->mls_line && pfile->mls_line != pfile->line)
|
||||
{
|
||||
cpp_error_with_line (pfile, pfile->mlstring_pos.line,
|
||||
pfile->mlstring_pos.col,
|
||||
cpp_error_with_line (pfile, pfile->mls_line, pfile->mls_col,
|
||||
"possible start of unterminated string literal");
|
||||
pfile->mlstring_pos.line = 0;
|
||||
pfile->mls_line = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -760,8 +758,11 @@ parse_string (pfile, token, terminator)
|
|||
cpp_pedwarn (pfile, "multi-line string literals are deprecated");
|
||||
}
|
||||
|
||||
if (pfile->mlstring_pos.line == 0)
|
||||
pfile->mlstring_pos = pfile->lexer_pos;
|
||||
if (pfile->mls_line == 0)
|
||||
{
|
||||
pfile->mls_line = token->line;
|
||||
pfile->mls_col = token->col;
|
||||
}
|
||||
|
||||
c = handle_newline (pfile, c);
|
||||
*dest++ = '\n';
|
||||
|
@ -998,7 +999,6 @@ lex_token (pfile, result)
|
|||
result->flags = buffer->saved_flags;
|
||||
buffer->saved_flags = 0;
|
||||
update_tokens_line:
|
||||
pfile->lexer_pos.line = pfile->line;
|
||||
result->line = pfile->line;
|
||||
|
||||
skipped_white:
|
||||
|
@ -1006,7 +1006,6 @@ lex_token (pfile, result)
|
|||
if (c == EOF && buffer->cur < buffer->rlimit)
|
||||
c = *buffer->cur++;
|
||||
result->col = CPP_BUF_COLUMN (buffer, buffer->cur);
|
||||
pfile->lexer_pos.col = result->col;
|
||||
buffer->read_ahead = EOF;
|
||||
|
||||
trigraph:
|
||||
|
@ -1171,9 +1170,7 @@ lex_token (pfile, result)
|
|||
|
||||
/* Skip_line_comment updates buffer->read_ahead. */
|
||||
if (skip_line_comment (pfile) && CPP_OPTION (pfile, warn_comments))
|
||||
cpp_warning_with_line (pfile, pfile->lexer_pos.line,
|
||||
pfile->lexer_pos.col,
|
||||
"multi-line comment");
|
||||
cpp_warning (pfile, "multi-line comment");
|
||||
}
|
||||
|
||||
/* Skipping the comment has updated buffer->read_ahead. */
|
||||
|
|
29
gcc/cpplib.c
29
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. */
|
||||
|
|
|
@ -605,9 +605,7 @@ funlike_invocation_p (pfile, node, list)
|
|||
{
|
||||
cpp_token maybe_paren;
|
||||
macro_arg *args = 0;
|
||||
cpp_lexer_pos macro_pos;
|
||||
|
||||
macro_pos = pfile->lexer_pos;
|
||||
pfile->state.parsing_args = 1;
|
||||
pfile->state.prevent_expansion++;
|
||||
|
||||
|
@ -630,10 +628,6 @@ funlike_invocation_p (pfile, node, list)
|
|||
pfile->state.parsing_args = 0;
|
||||
pfile->keep_tokens--;
|
||||
|
||||
/* Reset the position in case of failure. If success, the macro's
|
||||
expansion appears where the name would have. */
|
||||
pfile->lexer_pos = macro_pos;
|
||||
|
||||
if (args)
|
||||
{
|
||||
if (node->value.macro->paramc > 0)
|
||||
|
@ -1247,7 +1241,7 @@ _cpp_create_definition (pfile, node)
|
|||
|
||||
macro = (cpp_macro *) _cpp_pool_alloc (&pfile->macro_pool,
|
||||
sizeof (cpp_macro));
|
||||
macro->line = pfile->directive_pos.line;
|
||||
macro->line = pfile->directive_line;
|
||||
macro->params = 0;
|
||||
macro->paramc = 0;
|
||||
macro->fun_like = 0;
|
||||
|
@ -1345,8 +1339,7 @@ _cpp_create_definition (pfile, node)
|
|||
{
|
||||
if (warn_of_redefinition (pfile, node, macro))
|
||||
{
|
||||
cpp_pedwarn_with_line (pfile, pfile->directive_pos.line,
|
||||
pfile->directive_pos.col,
|
||||
cpp_pedwarn_with_line (pfile, pfile->directive_line, 0,
|
||||
"\"%s\" redefined", NODE_NAME (node));
|
||||
|
||||
if (node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
|
||||
|
|
Loading…
Add table
Reference in a new issue