re PR fortran/55919 (Bogus warning with -J directory/)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 21 Jan 2013 19:34:49 +0000 (19:34 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Mon, 21 Jan 2013 19:34:49 +0000 (19:34 +0000)
2013-01-21  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/55919
* scanner.c (add_path_to_list): Copy path to temporary and strip
trailing directory separators before calling stat().

2013-01-21  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/55919
* gfortran.dg/include_8.f90:  New test.

From-SVN: r195348

gcc/fortran/ChangeLog
gcc/fortran/scanner.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/include_8.f90 [new file with mode: 0644]

index 730c41b4e1fa391b3a7cc196e6f2c48b8cd39c30..126536b31c65f47fb3e220a7f5b2d17b1c01ca96 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/55919
+       * gfortran.dg/include_8.f90:  New test.
+
 2013-01-17  Richard Biener  <rguenther@suse.de>
 
        * trans-stmt.c (gfc_trans_do): Conditionally compute countm1
index 008e91f78b818deb52988ae12941f78b8a5b95cf..0467f8ac347caac450b5e901c2a1e8294e6aaffd 100644 (file)
@@ -310,14 +310,26 @@ add_path_to_list (gfc_directorylist **list, const char *path,
 {
   gfc_directorylist *dir;
   const char *p;
+  char *q;
   struct stat st;
+  size_t len;
+  int i;
   
   p = path;
   while (*p == ' ' || *p == '\t')  /* someone might do "-I include" */
     if (*p++ == '\0')
       return;
 
-  if (stat (p, &st))
+  /* Strip trailing directory separators from the path, as this
+     will confuse Windows systems.  */
+  len = strlen (p);
+  q = (char *) alloca (len + 1);
+  memcpy (q, p, len + 1);
+  i = len - 1;
+  while (i >=0 && IS_DIR_SEPARATOR(q[i]))
+    q[i--] = '\0';
+
+  if (stat (q, &st))
     {
       if (errno != ENOENT)
        gfc_warning_now ("Include directory \"%s\": %s", path,
index 0ca0c07391fb46cdddd154d3d0df193995a364fd..343611c25878693dbb79c2ed0ff389b69371a961 100644 (file)
@@ -1,3 +1,9 @@
+2013-01-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/55919
+       * add_path_to_list:  Copy path to temporary and strip
+       trailing directory separators before calling stat().
+
 2012-01-21  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/tree-ssa/pr55579.c: Cleanup esra tree dump.
diff --git a/gcc/testsuite/gfortran.dg/include_8.f90 b/gcc/testsuite/gfortran.dg/include_8.f90
new file mode 100644 (file)
index 0000000..84d0458
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! { dg-options "-J./" }
+! PR 55919 - a trailing dir separator would cause a warning
+! on Windows.
+program main
+end program main