[PATCH, libgfortran] Fix for PR 18982

Thomas Koenig Thomas.Koenig@online.de
Wed Jan 12 21:54:00 GMT 2005


Here's (again) a patch for PR 18982.  I've tried following
the conventions for the Changelog entries more closely now and
regenerated the patch (which was affected by one of the formatting
patches).

Original patch at http://gcc.gnu.org/ml/gcc-patches/2005-01/msg00024.html

Boostrapped and regression-tested on i386-unknown-linux-gnu,
without regressions.

Ok?

2005-01-12  Thomas Koenig  <Thomas.Koenig@online.de>

	PR libfortran/18982
	* io/unix.c: Use bitwise negation instead of logical
	negation to mask open flags

2005-01-12  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	12 Jan 2005 20:57:19 -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