diff options
Diffstat (limited to 'gcc/fortran/scanner.c')
-rw-r--r-- | gcc/fortran/scanner.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index c4e7974..33d96d8 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -2200,6 +2200,8 @@ load_file (const char *realfilename, const char *displayedname, bool initial) FILE *input; int len, line_len; bool first_line; + struct stat st; + int stat_result; const char *filename; /* If realfilename and displayedname are different and non-null then surely realfilename is the preprocessed form of @@ -2227,6 +2229,7 @@ load_file (const char *realfilename, const char *displayedname, bool initial) } else input = gfc_open_file (realfilename); + if (input == NULL) { gfc_error_now ("Can't open file %qs", filename); @@ -2242,6 +2245,15 @@ load_file (const char *realfilename, const char *displayedname, bool initial) current_file->filename, current_file->line, filename); return false; } + stat_result = stat (realfilename, &st); + if (stat_result == 0 && !(st.st_mode & S_IFREG)) + { + fprintf (stderr, "%s:%d: Error: Included path '%s'" + " is not a regular file\n", + current_file->filename, current_file->line, filename); + fclose (input); + return false; + } } /* Load the file. |