re PR fortran/36342 (Missing file name in compilation diagnostics of preprocessed...
authorTobias Burnus <burnus@net-b.de>
Sat, 19 Jul 2008 18:27:00 +0000 (20:27 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Sat, 19 Jul 2008 18:27:00 +0000 (20:27 +0200)
2008-07-19  Tobias Burnus  <burnus@net-b.de>

        PR fortran/36342
        * scanner.c (load_file): Add argument to destinguish between
        true filename and displayed filename.
        (include_line,gfc_new_file): Adapt accordingly.

From-SVN: r137985

gcc/fortran/ChangeLog
gcc/fortran/scanner.c

index 6077028..dc592ed 100644 (file)
@@ -1,5 +1,12 @@
 2008-07-19  Tobias Burnus  <burnus@net-b.de>
 
+       PR fortran/36342
+       * scanner.c (load_file): Add argument to destinguish between
+       true filename and displayed filename.
+       (include_line,gfc_new_file): Adapt accordingly.
+
+2008-07-19  Tobias Burnus  <burnus@net-b.de>
+
        * check.c (gfc_check_cshift,gfc_check_eoshift,gfc_check_unpack): Add rank
        checks for cshift's shift and eoshift's shift and boundary args.
        (gfc_check_unpack): Add rank and shape tests for unpack.
index 6e6017a..3087c62 100644 (file)
@@ -1672,7 +1672,7 @@ preprocessor_line (gfc_char_t *c)
 }
 
 
-static try load_file (const char *, bool);
+static try load_file (const char *, const char *, bool);
 
 /* include_line()-- Checks a line buffer to see if it is an include
    line.  If so, we call load_file() recursively to load the included
@@ -1743,7 +1743,7 @@ include_line (gfc_char_t *line)
                   read by anything else.  */
 
   filename = gfc_widechar_to_char (begin, -1);
-  load_file (filename, false);
+  load_file (filename, NULL, false);
   gfc_free (filename);
   return true;
 }
@@ -1752,7 +1752,7 @@ include_line (gfc_char_t *line)
 /* Load a file into memory by calling load_line until the file ends.  */
 
 static try
-load_file (const char *filename, bool initial)
+load_file (const char *realfilename, const char *displayedname, bool initial)
 {
   gfc_char_t *line;
   gfc_linebuf *b;
@@ -1760,6 +1760,9 @@ load_file (const char *filename, bool initial)
   FILE *input;
   int len, line_len;
   bool first_line;
+  const char *filename;
+
+  filename = displayedname ? displayedname : realfilename;
 
   for (f = current_file; f; f = f->up)
     if (strcmp (filename, f->filename) == 0)
@@ -1776,7 +1779,7 @@ load_file (const char *filename, bool initial)
          gfc_src_file = NULL;
        }
       else
-       input = gfc_open_file (filename);
+       input = gfc_open_file (realfilename);
       if (input == NULL)
        {
          gfc_error_now ("Can't open file '%s'", filename);
@@ -1785,7 +1788,7 @@ load_file (const char *filename, bool initial)
     }
   else
     {
-      input = gfc_open_included_file (filename, false, false);
+      input = gfc_open_included_file (realfilename, false, false);
       if (input == NULL)
        {
          gfc_error_now ("Can't open included file '%s'", filename);
@@ -1927,10 +1930,10 @@ gfc_new_file (void)
     {
       result = gfc_cpp_preprocess (gfc_source_file);
       if (!gfc_cpp_preprocess_only ())
-        result = load_file (gfc_cpp_temporary_file (), true);
+        result = load_file (gfc_cpp_temporary_file (), gfc_source_file, true);
     }
   else
-    result = load_file (gfc_source_file, true);
+    result = load_file (gfc_source_file, NULL, true);
 
   gfc_current_locus.lb = line_head;
   gfc_current_locus.nextc = (line_head == NULL) ? NULL : line_head->line;