[patch, fortran] Fix PR 54033, problems with -I

View: New views
2 Messages — Rating Filter:   Alert me  

[patch, fortran] Fix PR 54033, problems with -I

by Thomas Koenig-6 :: Rate this Message:

| View Threaded | Show Only this Message

Hello world,

the attached, rather obvious patch emits warnings for several
cases where there is something wrong with include directories.
No test case because I couldn't figure out how to test for a
warning with no line number.

OK for trunk?

        Thomas

2012-07-26  Thomas König  <tkoenig@...>

         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.

[p1.diff]

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);


Re: [patch, fortran] Fix PR 54033, problems with -I

by Janis Johnson-4 :: Rate this Message:

| View Threaded | Show Only this Message

On 07/26/2012 10:16 AM, Thomas Koenig wrote:

> No test case because I couldn't figure out how to test for a
> warning with no line number.

Try using line number 0.

Janis