From 15691205d709b57f5ed2d23f49f866dc2d0d5747 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 19 Apr 2011 09:19:33 +0000 Subject: [PATCH] backport: [multiple changes] 2011-04-19 Richard Guenther Backported from 4.6 branch 2011-03-29 Jakub Jelinek PR preprocessor/48248 * c-ppoutput.c (print): Add src_file field. (init_pp_output): Initialize it. (maybe_print_line): Don't optimize by adding up to 8 newlines if map->to_file and print.src_file are different file. (print_line): Update print.src_file. 2011-04-18 Richard Guenther PR preprocessor/48248 * c-ppoutput.c (maybe_print_line): Avoid changing -P behavior. From-SVN: r172703 --- gcc/ChangeLog | 17 +++++++++++++++++ gcc/c-ppoutput.c | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9bcbfcb8bc03..5732e342ba59 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2011-04-19 Richard Guenther + + Backported from 4.6 branch + 2011-03-29 Jakub Jelinek + + PR preprocessor/48248 + * c-ppoutput.c (print): Add src_file field. + (init_pp_output): Initialize it. + (maybe_print_line): Don't optimize by adding up to 8 newlines + if map->to_file and print.src_file are different file. + (print_line): Update print.src_file. + + 2011-04-18 Richard Guenther + + PR preprocessor/48248 + * c-ppoutput.c (maybe_print_line): Avoid changing -P behavior. + 2011-04-19 Richard Guenther PR tree-optimization/46188 diff --git a/gcc/c-ppoutput.c b/gcc/c-ppoutput.c index bd9af2aa0f6c..c72362cda658 100644 --- a/gcc/c-ppoutput.c +++ b/gcc/c-ppoutput.c @@ -37,6 +37,7 @@ static struct int src_line; /* Line number currently being written. */ unsigned char printed; /* Nonzero if something output at line. */ bool first_time; /* pp_file_change hasn't been called yet. */ + const char *src_file; /* Current source file. */ } print; /* Defined and undefined macros being queued for output with -dU at @@ -154,6 +155,7 @@ init_pp_output (FILE *out_stream) print.prev = 0; print.outf = out_stream; print.first_time = 1; + print.src_file = ""; } /* Writes out the preprocessed file, handling spacing and paste @@ -313,7 +315,9 @@ maybe_print_line (source_location src_loc) print.printed = 0; } - if (src_line >= print.src_line && src_line < print.src_line + 8) + if (src_line >= print.src_line + && src_line < print.src_line + 8 + && (flag_no_line_commands || strcmp (map->to_file, print.src_file) == 0)) { while (src_line > print.src_line) { @@ -345,6 +349,7 @@ print_line (source_location src_loc, const char *special_flags) unsigned char *p; print.src_line = SOURCE_LINE (map, src_loc); + print.src_file = map->to_file; /* cpp_quote_string does not nul-terminate, so we have to do it ourselves. */ -- 2.47.2