re PR fortran/54033 (gfortran: Passing file as include directory - add diagnostic...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 1 Aug 2012 21:43:50 +0000 (21:43 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 1 Aug 2012 21:43:50 +0000 (21:43 +0000)
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.

From-SVN: r190054

gcc/fortran/ChangeLog
gcc/fortran/scanner.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/include_3.f95
gcc/testsuite/gfortran.dg/include_6.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/include_7.f90 [new file with mode: 0644]

index 08dce7f3f5851228d694efbb2490d28fa9bf7929..a2b69d4575770c0637295bc333b47ca1b3b2a747 100644 (file)
@@ -1,3 +1,10 @@
+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-07-31  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/42418
index 4fad58b9148278b4edf42a3976a7fca7b1ddddaa..d4a27a845329ebfd83d176e9be748284c8b15ba3 100644 (file)
@@ -311,12 +311,29 @@ add_path_to_list (gfc_directorylist **list, const char *path,
 {
   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 0537caf2209db822f74364f473be2b0b4976e1f4..5c05d52e60de0dc722b2df591aed1623cafa7af1 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2012-08-01  Tom de Vries  <tom@codesourcery.com>
 
        * gcc.dg/tree-ssa/vrp76.c: New test.
index fba07cbb1f6b763b5985fa57cb06c282c47a46f4..1e429c41aaf9716f99ff58ad78d1bad8642483c4 100644 (file)
@@ -24,3 +24,4 @@ end function
 
 ! { dg-do compile }
 ! { dg-options "-fpreprocessed -g3" }
+! { dg-warning "Nonexistent include directory" "missing directory" { target *-*-* } 0 }
diff --git a/gcc/testsuite/gfortran.dg/include_6.f90 b/gcc/testsuite/gfortran.dg/include_6.f90
new file mode 100644 (file)
index 0000000..0bac390
--- /dev/null
@@ -0,0 +1,5 @@
+! { dg-do compile }
+! { dg-options "-I gfortran.log" }
+! { dg-warning "is not a directory" "" { target *-*-* } 0 }
+end 
+
diff --git a/gcc/testsuite/gfortran.dg/include_7.f90 b/gcc/testsuite/gfortran.dg/include_7.f90
new file mode 100644 (file)
index 0000000..9a30945
--- /dev/null
@@ -0,0 +1,5 @@
+! { dg-do compile }
+! { dg-options "-I nothere" }
+! { dg-warning "Nonexistent include directory" "missing directory" { target *-*-* } 0 }
+end 
+