public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] Fix PR 54033, problems with -I
@ 2012-07-26 17:16 Thomas Koenig
  2012-07-26 18:20 ` Janis Johnson
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas Koenig @ 2012-07-26 17:16 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

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@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.

[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 921 bytes --]

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-08-04 17:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-26 17:16 [patch, fortran] Fix PR 54033, problems with -I Thomas Koenig
2012-07-26 18:20 ` Janis Johnson
2012-07-27 20:31   ` Thomas Koenig
2012-07-27 22:15     ` Janis Johnson
2012-07-29 12:00       ` [patch, fortran] Fix PR 54033, problems with -I, with test cases Thomas Koenig
2012-07-31 13:50         ` Tobias Burnus
2012-08-02  8:54           ` Richard Guenther
2012-08-02  9:41             ` Tobias Burnus
2012-08-02 20:08               ` Thomas Koenig
2012-08-03 17:10                 ` Thomas Koenig
2012-08-04 17:31                   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).