Patchwork [fortran] Fix PR 54033, problems with -I, with test cases

login
register
mail settings
Submitter Thomas Koenig
Date July 29, 2012, 9:24 a.m.
Message ID <5015015F.6070303@netcologne.de>
Download mbox | patch
Permalink /patch/173905/
State New
Headers show

Comments

Thomas Koenig - July 29, 2012, 9:24 a.m.
Hello world,

here is an updated patch for PR 54033, this time with test cases.
Thanks to Janis for pointing me in the right direction with these.

Regression-tested. OK for trunk?

Thomas

2012-07-29  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-29  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.
Tobias Burnus - July 31, 2012, 1:47 p.m.
On 07/29/2012 11:24 AM, Thomas Koenig wrote:
> here is an updated patch for PR 54033, this time with test cases.
> Thanks to Janis for pointing me in the right direction with these.
> Regression-tested. OK for trunk?

Ok. Thanks for the patch - and to Janis for the first review.

Can you eliminate the extra line before "else if"?

Tobias

> 2012-07-29 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-29  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.
>
>
Richard Guenther - Aug. 2, 2012, 8:54 a.m.
On Tue, Jul 31, 2012 at 3:47 PM, Tobias Burnus <burnus@net-b.de> wrote:
> On 07/29/2012 11:24 AM, Thomas Koenig wrote:
>>
>> here is an updated patch for PR 54033, this time with test cases.
>> Thanks to Janis for pointing me in the right direction with these.
>> Regression-tested. OK for trunk?
>
>
> Ok. Thanks for the patch - and to Janis for the first review.
>
> Can you eliminate the extra line before "else if"?

Seems to break testing, all testcases emit

Warning: Nonexistent include directory "finclude"^M

now and thus all testcases fail like

FAIL: gfortran.dg/alloc_comp_basics_1.f90  -O0  (test for excess errors)

Richard.

> Tobias
>
>
>> 2012-07-29 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-29  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.
>>
>>
>
Tobias Burnus - Aug. 2, 2012, 9:40 a.m.
On 08/02/2012 10:54 AM, Richard Guenther wrote:
> Seems to break testing, all testcases emit
>
> Warning: Nonexistent include directory "finclude"^M
>
> now and thus all testcases fail like
>
> FAIL: gfortran.dg/alloc_comp_basics_1.f90  -O0  (test for excess errors)

First, I actually wonder why it only lists "finclude" and not the full 
pathname.

I think the problem is that gfortran (the driver) passes something like
    -fintrinsic-modules-path 
/$PREFIX/lib64/gcc/x86_64-unknown-linux-gnu/4.8.0/finclude
to the actual compiler (f951).

That directory only exists if the compiler is installed but not if one 
runs the test suite without installing it. I wonder how the OpenMP tests 
handle it - there one needs the files from that directory. (It currently 
contains the following files: omp_lib.f90 omp_lib.h  omp_lib_kinds.mod  
omp_lib.mod.) Answer: Theose seemingly include "$BUILD/$triplet/libgomp" 
in the -I path, which also contain those files. (That probably clashes 
with "use, intrinsic :: omp_lib", but that shouldn't matter.)

I am not sure whether it is the best solution, but one possibility would 
be to ignore -fintrinsic-modules-path for the warning. (That assumes 
that the warning is (almost) never needed for an installed compiler.)

Tobias

Patch

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 }