aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-03-29 22:25:27 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-03-29 22:25:27 +0200
commit22d17b1c681199b6bd0380010c56cddbb6b8d96b (patch)
tree694aa89b38234a2bb9ee479d1fa7c3bde396a87e /gcc
parent5d9cd5d0a712de44cb61dd809a525b7d16359ec7 (diff)
downloadgcc-22d17b1c681199b6bd0380010c56cddbb6b8d96b.zip
gcc-22d17b1c681199b6bd0380010c56cddbb6b8d96b.tar.gz
gcc-22d17b1c681199b6bd0380010c56cddbb6b8d96b.tar.bz2
re PR preprocessor/48248 (Wrong error message location when compiling preprocessed code)
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. From-SVN: r171693
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/c-family/c-ppoutput.c7
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d43f586..612af35 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2011-03-29 Jakub Jelinek <jakub@redhat.com>
+
+ 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-03-29 Vladimir Makarov <vmakarov@redhat.com>
* ira-conflicts.c (build_object_conflicts): Add unused attribute
diff --git a/gcc/c-family/c-ppoutput.c b/gcc/c-family/c-ppoutput.c
index 57ed676..9ebac42 100644
--- a/gcc/c-family/c-ppoutput.c
+++ b/gcc/c-family/c-ppoutput.c
@@ -36,6 +36,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
@@ -153,6 +154,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
@@ -312,7 +314,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
+ && strcmp (map->to_file, print.src_file) == 0)
{
while (src_line > print.src_line)
{
@@ -344,6 +348,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. */