This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR cpp/36674 #include location is offset by one row in errors from preprocessed files
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Joseph Myers <jsm at polyomino dot org dot uk>, Tom Tromey <tromey at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 21 Apr 2009 18:33:18 +0200
- Subject: Re: PR cpp/36674 #include location is offset by one row in errors from preprocessed files
- References: <6c33472e0808261008mcf0e84fl3c3eeee6d6e11bc6@mail.gmail.com> <6c33472e0810210854y201b8aadu64be80ac4706a9ed@mail.gmail.com>
PING2.
I have updated the patch to a recent revision, bootstrapped and
regression tested.
Cheers,
Manuel.
2008/10/21 Manuel López-Ibáñez <lopezibanez@gmail.com>:
> I have updated the patch to a recent revision, bootstrapped and
> regression tested.
>
> OK for trunk?
>
> Manuel.
>
> 2008/8/26 Manuel López-Ibáñez <lopezibanez@gmail.com>:
>> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
>> --enable-languages=all,ada
>>
>> OK for trunk?
>>
>> 2008-08-26 ?Manuel Lopez-Ibanez ?<manu@gcc.gnu.org>
>>
>> ? ? ? ?PR cpp/36674
>> libcpp/
>> ? ? ? ?* directives (do_linemarker): Compensate for the increment in
>> ? ? ? ?location that occurs when we reach the end of line.
>> ? ? ? ?* files (_cpp_stack_include): Mention _cpp_find_file in the
>> ? ? ? ?comment.
>> testsuite/
>> ? ? ? ?* gcc.dg/cpp/pr36674.i: New.
>>
>
Index: gcc/testsuite/gcc.dg/cpp/pr36674.i
===================================================================
--- gcc/testsuite/gcc.dg/cpp/pr36674.i (revision 0)
+++ gcc/testsuite/gcc.dg/cpp/pr36674.i (revision 0)
@@ -0,0 +1,12 @@
+/* PR cpp/36674 #include location is offset by one row in errors from preprocessed files */
+/* { dg-do compile } */
+/* { dg-options "-fshow-column" } */
+# 1 "gcc/testsuite/gcc.dg/pr36674.c"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "gcc/testsuite/gcc.dg/pr36674.c"
+# 1 "gcc/testsuite/gcc.dg/pr36674.h" 1
+not_declared_yet();
+# 1 "gcc/testsuite/gcc.dg/pr36674.c" 2
+/* { dg-message "file included from \[^\n\]*pr36674.c:1:" "correct include line" { target *-*-* } 0 } */
+/* { dg-message "pr36674.h:1:1: warning: data definition has no type or storage class" "correct warning" { target *-*-* } 0 } */
\ No newline at end of file
Index: libcpp/directives.c
===================================================================
--- libcpp/directives.c (revision 146528)
+++ libcpp/directives.c (working copy)
@@ -1002,10 +1002,18 @@ do_linemarker (cpp_reader *pfile)
cpp_token_as_text (pfile, token));
return;
}
skip_rest_of_line (pfile);
+
+ /* Compensate for the increment in linemap_add that occurs in
+ _cpp_do_file_change. We're currently at the start of the line
+ *following* the #line directive. A separate source_location for this
+ location makes no sense (until we do the LC_LEAVE), and
+ complicates LAST_SOURCE_LINE_LOCATION. */
+ pfile->line_table->highest_location--;
+
_cpp_do_file_change (pfile, reason, new_file, new_lineno, new_sysp);
}
/* Arrange the file_change callback. pfile->line has changed to
FILE_LINE of TO_FILE, for reason REASON. SYSP is 1 for a system
Index: libcpp/files.c
===================================================================
--- libcpp/files.c (revision 146528)
+++ libcpp/files.c (working copy)
@@ -910,17 +910,18 @@ _cpp_stack_include (cpp_reader *pfile, c
if (!dir)
return false;
file = _cpp_find_file (pfile, fname, dir, false, angle_brackets);
- /* Compensate for the increment in linemap_add. In the case of a
- normal #include, we're currently at the start of the line
- *following* the #include. A separate source_location for this
- location makes no sense (until we do the LC_LEAVE), and
- complicates LAST_SOURCE_LINE_LOCATION. This does not apply if we
- found a PCH file (in which case linemap_add is not called) or we
- were included from the command-line. */
+ /* Compensate for the increment in linemap_add that occurs in
+ _cpp_stack_file. In the case of a normal #include, we're
+ currently at the start of the line *following* the #include. A
+ separate source_location for this location makes no sense (until
+ we do the LC_LEAVE), and complicates LAST_SOURCE_LINE_LOCATION.
+ This does not apply if we found a PCH file (in which case
+ linemap_add is not called) or we were included from the
+ command-line. */
if (file->pchname == NULL && file->err_no == 0 && type != IT_CMDLINE)
pfile->line_table->highest_location--;
return _cpp_stack_file (pfile, file, type == IT_IMPORT);
}