diff mbox

[Fortran,committed] Fix issue in cpp.c's print_line

Message ID 505B81B8.1060501@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Sept. 20, 2012, 8:51 p.m. UTC
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 :-)
diff mbox

Patch

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);