This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran, committed] Fix issue in cpp.c's print_line
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Thu, 20 Sep 2012 22:51:04 +0200
- Subject: [Patch, Fortran, committed] Fix issue in cpp.c's print_line
gfortran was using
loc = expand_location (src_loc);
and then looked at "loc.sysp" value to decide whether it was a system
header with extern C or a normal system header.
However, loc.sysp is a bool! There is another "sysp" which is an
integer. As in gcc/c-family/c-ppoutput.c, one has to use
in_system_header_at to access it.
Successfully build on x86-64-linux and committed as Rev. 191590.
Tobias
PS: The issue was found by Coverity's static scanner :-)
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog (Revision 191588)
+++ gcc/fortran/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2012-09-20 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/54599
+ * cpp.c (print_line): Properly handle extern C.
+
2012-09-20 Martin Jambor <mjambor@suse.cz>
* trans-decl.c (gfc_get_extern_function_decl): Push NULL cfun. Do not
Index: gcc/fortran/cpp.c
===================================================================
--- gcc/fortran/cpp.c (Revision 191588)
+++ gcc/fortran/cpp.c (Arbeitskopie)
@@ -822,6 +822,7 @@ print_line (source_location src_loc, const char *s
size_t to_file_len;
unsigned char *to_file_quoted;
unsigned char *p;
+ int sysp;
loc = expand_location (src_loc);
to_file_len = strlen (loc.file);
@@ -838,9 +839,10 @@ print_line (source_location src_loc, const char *s
print.src_line == 0 ? 1 : print.src_line,
to_file_quoted, special_flags);
- if (loc.sysp == 2)
+ sysp = in_system_header_at (src_loc);
+ if (sysp == 2)
fputs (" 3 4", print.outf);
- else if (loc.sysp == 1)
+ else if (sysp == 1)
fputs (" 3", print.outf);
putc ('\n', print.outf);