aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-08-05 17:31:25 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-08-05 17:31:25 +0000
commit67821e3a9e007c34a85bbc3b934031b57eafc903 (patch)
tree37a35ef3c394621edd2c84f886dcc1310e94c38d /gcc/c-lex.c
parent8125d7e9ad4f1525e0e703f7610fd47cc628f047 (diff)
downloadgcc-67821e3a9e007c34a85bbc3b934031b57eafc903.zip
gcc-67821e3a9e007c34a85bbc3b934031b57eafc903.tar.gz
gcc-67821e3a9e007c34a85bbc3b934031b57eafc903.tar.bz2
re PR preprocessor/3081 (Preprocessor merges 2 first lines when -imacros is being used)
PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. (cb_def_pragma, cb_define, cb_undef): Use map and line. (c_lex): Update to use map. * cpperror.c (print_location): Move to using logical line numbers. * cppfiles.c (stack_include_file): Update for new _cpp_do_file_change. (cpp_make_system_header): Similarly. (_cpp_execute_include): Stop line numbering hacks. Store the line we will return to. * cpphash.h (CPP_BUF_LINE): Remove. (struct cpp_buffer): Remove lineno and pseudo_newlines. Add map and return_to_line. (_cpp_do_file_change): Update. * cppinit.c (cpp_start_read): Update line kludge. * cpplex.c (handle_newline): Don't update lineno and pseudo_newlines. (trigraph_ok): Use logical line numbers for diagnostics. (skip_block_comment): Likewise. (skip_whitespace): Likewise. (skip_line_comment): Use pfile->line instead. (_cpp_lex_token): Update to use logical line numbering exclusively. Handle BOL locally. Accept new lines in directives, but keep pfile->line decremented. Diagnostics use logical lines. Update directive handling. * cpplib.c (SEEN_EOL): New. (skip_rest_of_line, check_eol): Use it. (end_directive): Increase line number when accepting the newline at the end of a directive. (run_directive): Simplify. (do_line): Bad LC_LEAVEs become LC_RENAMEs. Update. (_cpp_do_file_change): Update to take buffer line number as an argument, and store the current map in the cpp_reader. Remove line number kludges. (_cpp_do__Pragma): Restore output position after a _Pragma. (cpp_push_buffer): Don't set output line or lineno. (_cpp_pop_buffer): Transfer more info from a faked buffer. Remove line kludge. Set output_line. * cppmacro.c (builtin_macro): Update handling of __LINE__. (parse_arg): Use logical lines. (save_lookahead_token): Save EOFs too now. * cppmain.c (struct printer): Fix comments. (printer_init): Simplify, let caller do errors. (scan_translation_unit, check_multiline_token, dump_macro): Update. (maybe_print_line): Simplify. (print_line): Don't print a linemarker if -P. (cb_define, cb_undef, cb_def_pragma, cb_ident, cb_include): Update. (cb_file_change): Simplify. * line-map.h (LAST_SOURCE_LINE): Fix. (CURRENT_LINE_MAP): New. * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. From-SVN: r44650
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 89e1702..971d9cd 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -57,6 +57,9 @@ Boston, MA 02111-1307, USA. */
/* The input filename as understood by CPP, where "" represents stdin. */
static const char *cpp_filename;
+/* The current line map. */
+static struct line_map *map;
+
/* We may keep statistics about how long which files took to compile. */
static int header_time, body_time;
static splay_tree file_info_tree;
@@ -301,9 +304,10 @@ cb_file_change (pfile, fc)
}
update_header_times (fc->map->to_file);
+ map = fc->map;
in_system_header = fc->sysp != 0;
- input_filename = fc->map->to_file;
- lineno = SOURCE_LINE (fc->map, fc->line); /* Do we need this? */
+ input_filename = map->to_file;
+ lineno = SOURCE_LINE (map, fc->line);
/* Hook for C++. */
extract_interface_info ();
@@ -312,7 +316,7 @@ cb_file_change (pfile, fc)
static void
cb_def_pragma (pfile, line)
cpp_reader *pfile;
- unsigned int line ATTRIBUTE_UNUSED;
+ unsigned int line;
{
/* Issue a warning message if we have been asked to do so. Ignore
unknown pragmas in system headers unless an explicit
@@ -328,7 +332,7 @@ cb_def_pragma (pfile, line)
if (s.type == CPP_NAME)
name = cpp_token_as_text (pfile, &s);
- lineno = cpp_get_line (parse_in)->line;
+ lineno = SOURCE_LINE (map, line);
if (name)
warning ("ignoring #pragma %s %s", space, name);
else
@@ -340,21 +344,21 @@ cb_def_pragma (pfile, line)
static void
cb_define (pfile, line, node)
cpp_reader *pfile;
- unsigned int line ATTRIBUTE_UNUSED;
+ unsigned int line;
cpp_hashnode *node;
{
- (*debug_hooks->define) (cpp_get_line (pfile)->line,
+ (*debug_hooks->define) (SOURCE_LINE (map, line),
(const char *) cpp_macro_definition (pfile, node));
}
/* #undef callback for DWARF and DWARF2 debug info. */
static void
cb_undef (pfile, line, node)
- cpp_reader *pfile;
- unsigned int line ATTRIBUTE_UNUSED;
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ unsigned int line;
cpp_hashnode *node;
{
- (*debug_hooks->undef) (cpp_get_line (pfile)->line,
+ (*debug_hooks->undef) (SOURCE_LINE (map, line),
(const char *) NODE_NAME (node));
}
@@ -763,7 +767,7 @@ c_lex (value)
/* The C++ front end does horrible things with the current line
number. To ensure an accurate line number, we must reset it
every time we return a token. */
- lineno = cpp_get_line (parse_in)->line;
+ lineno = SOURCE_LINE (map, cpp_get_line (parse_in)->line);
*value = NULL_TREE;
type = tok.type;