This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, libcpp] Do not decrease highest_location if the included file has be included twice.
- From: Dehao Chen <dehao at google dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Biener <richard dot guenther at gmail dot com>
- Date: Sat, 1 Jun 2013 07:55:21 -0700
- Subject: [PATCH, libcpp] Do not decrease highest_location if the included file has be included twice.
This patch fixes the bug that when include a header file, if the
header file is already included (with #define _HEADER_H_), libcpp
should not decrease its highest_location, otherwise it'll cause
incorrect source location when source location numbers are large
enough to omit columns.
Passed regression test.
OK for trunk?
Thanks,
Dehao
libcpp/ChangeLog:
2013-05-31 Dehao Chen <dehao@google.com>
* files.c (_cpp_stack_include): Fix the highest_location when header
file is guarded by #ifndef and is included twice.
Index: libcpp/files.c
===================================================================
--- libcpp/files.c (revision 199416)
+++ libcpp/files.c (working copy)
@@ -1002,7 +1002,8 @@ _cpp_stack_include (cpp_reader *pfile, const char
linemap_add is not called) or we were included from the
command-line. */
if (file->pchname == NULL && file->err_no == 0
- && type != IT_CMDLINE && type != IT_DEFAULT)
+ && type != IT_CMDLINE && type != IT_DEFAULT
+ && !(file->cmacro && file->cmacro->type == NT_MACRO))
pfile->line_table->highest_location--;
return _cpp_stack_file (pfile, file, type == IT_IMPORT);