aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 783732f..c53a996 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -282,7 +282,7 @@ _cpp_process_line_notes (cpp_reader *pfile, int in_comment)
}
buffer->line_base = note->pos;
- pfile->line++;
+ CPP_INCREMENT_LINE (pfile, 0);
}
else if (_cpp_trigraph_map[note->type])
{
@@ -349,12 +349,16 @@ _cpp_skip_block_comment (cpp_reader *pfile)
}
else if (c == '\n')
{
+ unsigned int cols;
buffer->cur = cur - 1;
_cpp_process_line_notes (pfile, true);
if (buffer->next_line >= buffer->rlimit)
return true;
_cpp_clean_line (pfile);
- pfile->line++;
+
+ cols = buffer->next_line - buffer->line_base;
+ CPP_INCREMENT_LINE (pfile, cols);
+
cur = buffer->cur;
}
}
@@ -680,8 +684,7 @@ _cpp_temp_token (cpp_reader *pfile)
}
result = pfile->cur_token++;
- result->line = old->line;
- result->col = old->col;
+ result->src_loc = old->src_loc;
return result;
}
@@ -772,7 +775,7 @@ _cpp_get_fresh_line (cpp_reader *pfile)
{
/* Only warn once. */
buffer->next_line = buffer->rlimit;
- cpp_error_with_line (pfile, CPP_DL_PEDWARN, pfile->line - 1,
+ cpp_error_with_line (pfile, CPP_DL_PEDWARN, pfile->line,
CPP_BUF_COLUMN (buffer, buffer->cur),
"no newline at end of file");
}
@@ -822,7 +825,7 @@ _cpp_lex_direct (cpp_reader *pfile)
if (!pfile->state.in_directive)
{
/* Tell the compiler the line number of the EOF token. */
- result->line = pfile->line;
+ result->src_loc = pfile->line;
result->flags = BOL;
}
return result;
@@ -839,17 +842,19 @@ _cpp_lex_direct (cpp_reader *pfile)
}
buffer = pfile->buffer;
update_tokens_line:
- result->line = pfile->line;
+ result->src_loc = pfile->line;
skipped_white:
if (buffer->cur >= buffer->notes[buffer->cur_note].pos
&& !pfile->overlaid_buffer)
{
_cpp_process_line_notes (pfile, false);
- result->line = pfile->line;
+ result->src_loc = pfile->line;
}
c = *buffer->cur++;
- result->col = CPP_BUF_COLUMN (buffer, buffer->cur);
+
+ result->src_loc = linemap_position_for_column (pfile->line_table,
+ CPP_BUF_COLUMN (buffer, buffer->cur));
switch (c)
{
@@ -859,7 +864,8 @@ _cpp_lex_direct (cpp_reader *pfile)
goto skipped_white;
case '\n':
- pfile->line++;
+ if (buffer->cur < buffer->rlimit)
+ CPP_INCREMENT_LINE (pfile, 0);
buffer->need_line = true;
goto fresh_line;
@@ -916,7 +922,7 @@ _cpp_lex_direct (cpp_reader *pfile)
cpp_error (pfile, CPP_DL_ERROR, "unterminated comment");
}
else if (c == '/' && (CPP_OPTION (pfile, cplusplus_comments)
- || CPP_IN_SYSTEM_HEADER (pfile)))
+ || cpp_in_system_header (pfile)))
{
/* Warn about comments only if pedantically GNUC89, and not
in system headers. */