This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH] Fix for PR fortran/38956
- From: David Billinghurst <dbcygwin at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Fri, 30 Jan 2009 12:58:21 +1100
- Subject: PATCH] Fix for PR fortran/38956
PR PR38956 is the failure of testsuite/gfortran.dg/chmod_{1,2,3}.f90 on i686-pc-cygwin.
The problem is due to a mismatch between Windows and POSIX file access models.
Under Windows, accounts with Administrator rights can write to any file
regardless of the file permission. There is no easy way to check for this
from Fortran.
This patch removes the failing parts of tests chmod_{1,2,3}.f90 and
adds them to a new test chmod_4.f90
Likewise for gfortran.dg/open_errors.f90.
2009-01-29 David Billinghurst (billingd@gcc.gnu.org)
PR fortran/38956
* gfortran.dg/chmod_1.f90: Remove test that fails on cygwin
* gfortran.dg/chmod_2.f90: Likewise
* gfortran.dg/chmod_3.f90: Likewise
* gfortran.dg/open_errors.f90: Likewise
* gfortran.dg/chmod_4.f90: New test with failing tests above.
* gfortran.dg/open_errors_2.f90: Likewise
Index: chmod_1.f90
===================================================================
--- chmod_1.f90 (revision 143773)
+++ chmod_1.f90 (working copy)
@@ -19,11 +19,6 @@
if (access(n,"x") /= 0 .or. access(n,"X") /= 0) call abort
end if
- call chmod (n, "a-w", i)
- if (i == 0 .and. getuid() /= 0) then
- if (access(n,"w") == 0 .or. access(n,"W") == 0) call abort
- end if
-
open (10,file=n)
close (10,status="delete")
Index: chmod_2.f90
===================================================================
--- chmod_2.f90 (revision 143773)
+++ chmod_2.f90 (working copy)
@@ -19,11 +19,6 @@
if (access(n,"x") /= 0 .or. access(n,"X") /= 0) call abort
end if
- i = chmod (n, "a-w")
- if (i == 0 .and. getuid() /= 0) then
- if (access(n,"w") == 0 .or. access(n,"W") == 0) call abort
- end if
-
open (10,file=n)
close (10,status="delete")
Index: chmod_3.f90
===================================================================
--- chmod_3.f90 (revision 143773)
+++ chmod_3.f90 (working copy)
@@ -19,11 +19,6 @@
if (access(n,"x") /= 0 .or. access(n,"X") /= 0) call abort
end if
- i = chmod (n, "a-w")
- if (i == 0 .and. getuid() /= 0) then
- if (access(n,"w") == 0 .or. access(n,"W") == 0) call abort
- end if
-
open (10,file=n)
close (10,status="delete")
Index: open_errors.f90
===================================================================
--- open_errors.f90 (revision 143777)
+++ open_errors.f90 (working copy)
@@ -25,13 +25,6 @@
open(77,file=n,status="new")
i = chmod(n, "-w")
-if (i == 0 .and. getuid() /= 0) then
- close(77, status="keep")
- open(77,file=n, iomsg=msg, iostat=i, action="write")
- if (i == 0) call abort()
- if (msg /= "Permission denied trying to open file 'temptestfile'") call abort()
-endif
-
i = chmod(n,"+w")
open(77,file=n, iomsg=msg, iostat=i, action="read")
close(77, status="delete")
--- /dev/null 2004-09-08 02:21:19.000000000 +1000
+++ chmod_4.f90 2009-01-30 11:08:13.000000000 +1100
@@ -0,0 +1,30 @@
+! { dg-do run { target { { ! *-*-mingw* } && { ! *-*-cygwin* } } } }
+! { dg-options "-std=gnu" }
+! See PR38956. Test will fail on cygwin when run with Administrator rights
+ implicit none
+ character(len=*), parameter :: n = "foobar_file"
+ integer :: i
+
+ open (10,file=n)
+ close (10,status="delete")
+
+ open (10,file=n)
+ close (10,status="keep")
+
+ if (access(n,"") /= 0 .or. access(n," ") /= 0 .or. access(n,"r") /= 0 .or. &
+ access(n,"R") /= 0 .or. access(n,"w") /= 0 .or. access(n,"W") /= 0) &
+ call abort
+
+ call chmod (n, "a-w", i)
+ if (i == 0 .and. getuid() /= 0) then
+ if (access(n,"w") == 0 .or. access(n,"W") == 0) call abort
+ end if
+
+ open (10,file=n)
+ close (10,status="delete")
+
+ if (access(n,"") == 0 .or. access(n," ") == 0 .or. access(n,"r") == 0 .or. &
+ access(n,"R") == 0 .or. access(n,"w") == 0 .or. access(n,"W") == 0) &
+ call abort
+
+ end
--- /dev/null 2004-09-08 02:21:19.000000000 +1000
+++ open_errors_2.f90 2009-01-30 12:52:01.000000000 +1100
@@ -0,0 +1,25 @@
+! { dg-do run { target { { ! *-*-mingw* } && { ! *-*-cygwin* } } } }
+! PR30005 Enhanced error messages for OPEN
+! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
+! See PR38956. Test will fail on cygwin when run with Administrator rights
+character(60) :: msg
+character(25) :: n = "temptestfile"
+logical :: there
+inquire(file=n, exist=there)
+if (there) then
+ open(77,file=n,status="old")
+ close(77, status="delete")
+endif
+
+open(77,file=n,status="new")
+i = chmod(n, "-w")
+if (i == 0 .and. getuid() /= 0) then
+ close(77, status="keep")
+ open(77,file=n, iomsg=msg, iostat=i, action="write")
+ if (i == 0) call abort()
+ if (msg /= "Permission denied trying to open file 'temptestfile'") call abort()
+endif
+
+i = chmod(n,"+w")
+close(77, status="delete")
+end