Patch for PR 18982
Thomas Koenig
Thomas.Koenig@online.de
Sat Jan 1 22:03:00 GMT 2005
This is a patch for PR 18982. The patch was bubblestrapped on
i686-unknown-linux-gnu, with no regressions.
I hereby donate this rather trivial patch to the FSF, since I
don't have a copyright assignment with the FSF on file. I hope
that this is sufficient. If not, the gfortran developers are
cordially invited to reverse engineer the patch and find their
own solutions :-)
2005-01-01 Thomas Koenig <Thomas.Koenig@online.de>
* io/unix.c: Use bitwise negation instead of logical
negation to mask open flags
2005-01-01 Thomas Koenig <Thomas.Koenig@online.de>
* gfortran.dg/open_new.f90: new testcase
-------------- next part --------------
Index: unix.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.18
diff -c -r1.18 unix.c
*** unix.c 8 Dec 2004 00:32:39 -0000 1.18
--- unix.c 1 Jan 2005 16:01:22 -0000
***************
*** 1060,1070 ****
{
if (fd < 0)
{
! rwflag = rwflag & !O_RDWR | O_RDONLY;
fd = open (path, rwflag, mode);
if (fd < 0)
{
! rwflag = rwflag & !O_RDONLY | O_WRONLY;
fd = open (path, rwflag, mode);
if (fd < 0)
flags->action = ACTION_READWRITE; /* Could not open at all. */
--- 1060,1070 ----
{
if (fd < 0)
{
! rwflag &= ~(O_RDWR | O_RDONLY);
fd = open (path, rwflag, mode);
if (fd < 0)
{
! rwflag &= ~(O_RDONLY | O_WRONLY);
fd = open (path, rwflag, mode);
if (fd < 0)
flags->action = ACTION_READWRITE; /* Could not open at all. */
-------------- next part --------------
! { dg do-run }
! PR 18982: verifies that opening an existing file with
! status="new" is an error
program main
nout = 10
open(nout, file="foo.dat", status="replace") ! make sure foo.dat exists
close(nout)
open(nout, file="foo.dat", status="new",err=100)
call abort ! This should never happen
100 continue
end program main
More information about the Fortran
mailing list