From 1ea7ed2119257b80d0327b5c3d979cebd87aa894 Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 5 Aug 2001 17:31:25 +0000 Subject: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44650 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cpphash.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gcc/cpphash.h') diff --git a/gcc/cpphash.h b/gcc/cpphash.h index 1abeb574990..1ba4282561b 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -35,7 +35,6 @@ struct directive; /* Deliberately incomplete. */ #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION) #define CPP_BUFFER(PFILE) ((PFILE)->buffer) -#define CPP_BUF_LINE(BUF) ((BUF)->lineno) #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base + (BUF)->col_adjust) #define CPP_BUF_COL(BUF) CPP_BUF_COLUMN(BUF, (BUF)->cur) @@ -194,8 +193,10 @@ struct cpp_buffer /* Token column position adjustment owing to tabs in whitespace. */ unsigned int col_adjust; - /* Line number at line_base (above). */ - unsigned int lineno; + /* The line of the buffer that we return to after a #include. + Strictly this is redundant, since it can be calculated from the + line maps, but it is clearest to save it here. */ + unsigned int return_to_line; /* Contains PREV_WHITE and/or AVOID_LPASTE. */ unsigned char saved_flags; @@ -251,12 +252,10 @@ struct cpp_reader /* Lexer state. */ struct lexer_state state; - /* Source line tracking. Subtract pseudo_newlines from the actual - line number to get the line number of preprocessed output. Used - for escaped newlines and macro args that cross multiple lines. */ + /* Source line tracking. */ struct line_maps line_maps; + struct line_map *map; unsigned int line; - unsigned int pseudo_newlines; /* The position of the last lexed token and last lexed directive. */ cpp_lexer_pos lexer_pos; @@ -446,7 +445,8 @@ extern void _cpp_define_builtin PARAMS ((cpp_reader *, const char *)); extern void _cpp_do__Pragma PARAMS ((cpp_reader *)); extern void _cpp_init_directives PARAMS ((cpp_reader *)); extern void _cpp_init_internal_pragmas PARAMS ((cpp_reader *)); -extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum lc_reason)); +extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum lc_reason, + unsigned int)); extern void _cpp_pop_buffer PARAMS ((cpp_reader *)); /* Utility routines and macros. */ -- cgit v1.2.1