From a1c7eda2d5ee7ffde5e8ff23e0fec3cea03fea0b Mon Sep 17 00:00:00 2001 From: bothner Date: Thu, 2 Oct 2003 07:03:42 +0000 Subject: [PATCH] * c-lex.c (fe_file_change): Handle a NULL new_map. * fix-header.c (cb_file_change): Likewise. * c-ppoutput.c (pp_file_change): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72011 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 4 ++++ gcc/c-lex.c | 6 ++++++ gcc/c-ppoutput.c | 37 ++++++++++++++++++++----------------- gcc/fix-header.c | 2 +- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3bad4170169..2cd52af9f7c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -5,6 +5,10 @@ (get_non_padding_token): We no longer need to compensate for the "horrible things" the C++ front-end does with the current line number, + * c-lex.c (fe_file_change): Handle a NULL new_map. + * fix-header.c (cb_file_change): Likewise. + * c-ppoutput.c (pp_file_change): Likewise. + 2003-10-01 Zack Weinberg * target.h (init_libfuncs): New hook. diff --git a/gcc/c-lex.c b/gcc/c-lex.c index f3cdd3cffb0..5546fc9ddd1 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -212,6 +212,12 @@ cb_dir_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const char *dir) void fe_file_change (const struct line_map *new_map) { + if (new_map == NULL) + { + map = NULL; + return; + } + if (new_map->reason == LC_ENTER) { /* Don't stack the main buffer on the input stack; diff --git a/gcc/c-ppoutput.c b/gcc/c-ppoutput.c index 669d11ea494..22e595f9541 100644 --- a/gcc/c-ppoutput.c +++ b/gcc/c-ppoutput.c @@ -346,24 +346,27 @@ pp_file_change (const struct line_map *map) if (flag_no_line_commands || flag_no_output) return; - /* First time? */ - if (print.map == NULL) + if (map != NULL) { - /* Avoid printing foo.i when the main file is foo.c. */ - if (!cpp_get_options (parse_in)->preprocessed) - print_line (map, map->from_line, flags); - } - else - { - /* Bring current file to correct line when entering a new file. */ - if (map->reason == LC_ENTER) - maybe_print_line (map - 1, map->from_line - 1); - - if (map->reason == LC_ENTER) - flags = " 1"; - else if (map->reason == LC_LEAVE) - flags = " 2"; - print_line (map, map->from_line, flags); + /* First time? */ + if (print.map == NULL) + { + /* Avoid printing foo.i when the main file is foo.c. */ + if (!cpp_get_options (parse_in)->preprocessed) + print_line (map, map->from_line, flags); + } + else + { + /* Bring current file to correct line when entering a new file. */ + if (map->reason == LC_ENTER) + maybe_print_line (map - 1, map->from_line - 1); + + if (map->reason == LC_ENTER) + flags = " 1"; + else if (map->reason == LC_LEAVE) + flags = " 2"; + print_line (map, map->from_line, flags); + } } print.map = map; diff --git a/gcc/fix-header.c b/gcc/fix-header.c index 0f5f8c0d423..8ae3025b15d 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -578,7 +578,7 @@ cb_file_change (cpp_reader *pfile ATTRIBUTE_UNUSED, const struct line_map *map) { /* Just keep track of current file name. */ - cur_file = map->to_file; + cur_file = map == NULL ? NULL : map->to_file; } static void -- 2.11.0