Index: fortran/scanner.c =================================================================== --- fortran/scanner.c (Revision 189754) +++ fortran/scanner.c (Arbeitskopie) @@ -311,12 +311,30 @@ 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 ("Nonexistent include directory \"%s\"", 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); Index: testsuite/gfortran.dg/include_3.f95 =================================================================== --- testsuite/gfortran.dg/include_3.f95 (Revision 189754) +++ testsuite/gfortran.dg/include_3.f95 (Arbeitskopie) @@ -24,3 +24,4 @@ end function ! { dg-do compile } ! { dg-options "-fpreprocessed -g3" } +! { dg-warning "Nonexistent include directory" "missing directory" { target *-*-* } 0 }