Report error when -fpre-include can't be opened (PR fortran/88912).
authorMartin Liska <mliska@suse.cz>
Mon, 4 Feb 2019 12:20:59 +0000 (13:20 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 4 Feb 2019 12:20:59 +0000 (12:20 +0000)
2019-02-04  Martin Liska  <mliska@suse.cz>

PR fortran/88912
* scanner.c (load_file): Report error for -fpre-include
file and do not ICE.

From-SVN: r268517

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

index 6f0e9e694955f2295aa71ed4856364b72d50e25c..c3b4a5c0ff6a1e546475981bbf6ae4e8c91db50b 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-04  Martin Liska  <mliska@suse.cz>
+
+       PR fortran/88912
+       * scanner.c (load_file): Report error for -fpre-include
+       file and do not ICE.
+
 2019-02-02  Dominique d'Humieres  <dominiq@gcc.gnu.org>
 
        PR fortran/81344
index efb6ebf9509df3239039b6e6295331623f4ece76..08e4521a86dc8271242046328ea0b283bb40310f 100644 (file)
@@ -2478,8 +2478,14 @@ load_file (const char *realfilename, const char *displayedname, bool initial)
       input = gfc_open_included_file (realfilename, false, false);
       if (input == NULL)
        {
-         fprintf (stderr, "%s:%d: Error: Can't open included file '%s'\n",
-                  current_file->filename, current_file->line, filename);
+         /* For -fpre-include file, current_file is NULL.  */
+         if (current_file)
+           fprintf (stderr, "%s:%d: Error: Can't open included file '%s'\n",
+                    current_file->filename, current_file->line, filename);
+         else
+           fprintf (stderr, "Error: Can't open pre-included file '%s'\n",
+                    filename);
+
          return false;
        }
       stat_result = stat (realfilename, &st);