Based on the report by Vladimír Fuka at http://gcc.gnu.org/ml/fortran/2012-07/msg00089.html Do: touch file gfortran -I file test.f90 Result: Nothing. Expected: As with gcc: cc1: warning: foo: not a directory [enabled by default] (That's in gcc/incpath.c's remove_duplicates - which is publical accessible via register_include_chains -> merge_include_chains -> remove_duplicates) If one uses the preprocessor (-cpp), one even gets an ICE: Program received signal SIGABRT, Aborted. #1 0x00002aaaabe0f1a8 in __GI_abort () at abort.c:91 #2 0x0000000000e56a27 in cpp_diagnostic_with_line (pfile=0x16a1450, level=<optimized out>, reason=<optimized out>, src_loc=<optimized out>, column=<optimized out>, msgid=<optimized out>, ap=0x7fffffffd948) at libcpp/errors.c:145 #3 0x0000000000e56d29 in cpp_error_with_line (pfile=<optimized out>, level=<optimized out>, src_loc=<optimized out>, column=<optimized out>, msgid=<optimized out>) at libcpp/errors.c:164 #4 0x000000000085a07a in remove_duplicates (pfile=pfile@entry=0x16a1450, head=0x16a10e0, system=0x16bd1a0, join=0x16bd1a0, verbose=verbose@entry=1) at gcc/incpath.c:251 #5 0x000000000085a582 in merge_include_chains (verbose=1, pfile=0x16a1450, sysroot=0x0) at gcc/incpath.c:341 #6 register_include_chains (pfile=<optimized out>, sysroot=0x0, iprefix=0x0, imultilib=0x0, stdinc=1, cxx_stdinc=<optimized out>, verbose=1) at gcc/incpath.c:466 #7 0x0000000000562c88 in gfc_cpp_register_include_paths () at gcc/fortran/cpp.c:694
This patch looks OK so far. Index: scanner.c =================================================================== --- scanner.c (Revision 189754) +++ scanner.c (Arbeitskopie) @@ -311,12 +311,31 @@ add_path_to_list (gfc_directorylist **list, const { gfc_directorylist *dir; const char *p; - + struct stat st; + p = path; while (*p == ' ' || *p == '\t') /* someone might do "-I include" */ if (*p++ == '\0') return; + if (stat (p, &st)) + { + if (errno != ENOENT) + gfc_warning_now ("Include directory \"%s\": %s", path, + xstrerror(errno)); + else + /* FIXME: Also support -Wmissing-include-dirs. */ + gfc_warning_now ("Include directory \"%s\" does not exist", + path); + return; + } + + else if (!S_ISDIR (st.st_mode)) + { + gfc_warning_now ("\"%s\" is not a directory", path); + return; + } + if (head || *list == NULL) { dir = XCNEW (gfc_directorylist);
Author: tkoenig Date: Wed Aug 1 21:43:50 2012 New Revision: 190054 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190054 Log: 2012-08-01 Thomas König <tkoenig@gcc.gnu.org> PR fortran/54033 * scanner.c (add_path_to_list): Emit warning if an error occurs for an include path, if it is not present or if it is not a directory. Do not add the path in these cases. 2012-08-01 Thomas König <tkoenig@gcc.gnu.org> PR fortran/54033 * gfortran.dg/include_6.f90: New test case. * gfortran.dg/include_7.f90: New test case. * gfortran.dg/include_3.f90: Add dg-warning for missing directory. Added: trunk/gcc/testsuite/gfortran.dg/include_6.f90 trunk/gcc/testsuite/gfortran.dg/include_7.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/scanner.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/include_3.f95
Fixed on trunk, closing. Thanks for the bug report!
Author: hjl Date: Sat Aug 4 18:26:56 2012 New Revision: 190144 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190144 Log: Fix PR 54033, problems with -I, with test cases PR fortran/54033 * scanner.c (add_path_to_list): New argument warn. Don't warn if it is true. (gfc_add_include_path): Warn if directory is missing. (gfc_add_intrinsic_modules_path): Do not warn if directory is missing. * optinons.c (gfc_handle_option): Do not add directory for intrinsic modules to normal include path. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/options.c trunk/gcc/fortran/scanner.c
Really closing.