From fcd698d713c9864cd17b3df3272d0cc99d4a07fe Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 4 Feb 2019 13:20:59 +0100 Subject: [PATCH] Report error when -fpre-include can't be opened (PR fortran/88912). 2019-02-04 Martin Liska PR fortran/88912 * scanner.c (load_file): Report error for -fpre-include file and do not ICE. From-SVN: r268517 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/scanner.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6f0e9e69495..c3b4a5c0ff6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-02-04 Martin Liska + + PR fortran/88912 + * scanner.c (load_file): Report error for -fpre-include + file and do not ICE. + 2019-02-02 Dominique d'Humieres PR fortran/81344 diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index efb6ebf9509..08e4521a86d 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -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); -- 2.30.2