OSDN Git Service

PR fortran/24892
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Nov 2005 12:46:57 +0000 (12:46 +0000)
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Nov 2005 12:46:57 +0000 (12:46 +0000)
* io/io.h (unit_access): Add ACCESS_APPEND.
* io/open.c (access_opt): Add APPEND value for ACCESS keyword.
(st_open): Use that new value to set the POSITION accordingly.

* gfortran.dg/open_access_append_1.f90: New test.
* gfortran.dg/open_access_append_2.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107119 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/open_access_append_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/open_access_append_2.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/io.h
libgfortran/io/open.c

index dbc0b69..db4aa5a 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-17  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/24892
+       * gfortran.dg/open_access_append_1.f90: New test.
+       * gfortran.dg/open_access_append_2.f90: New test.
+
 2005-11-16  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/24851
diff --git a/gcc/testsuite/gfortran.dg/open_access_append_1.f90 b/gcc/testsuite/gfortran.dg/open_access_append_1.f90
new file mode 100644 (file)
index 0000000..7aa7991
--- /dev/null
@@ -0,0 +1,20 @@
+! { dg-do run }
+! Testcase for the GNU extension OPEN(...,ACCESS="APPEND")
+  open (10,file="foo")
+  close (10,status="delete")
+
+  open (10,file="foo",access="append") ! { dg-output ".*Extension.*" }
+  write (10,*) 42
+  close (10,status="keep")
+  open (10,file="foo",access="append") ! { dg-output ".*Extension.*" }
+  write (10,*) -42
+  close (10,status="keep")
+
+  open (10,file="foo")
+  read (10,*) i
+  if (i /= 42) call abort
+  read (10,*) i
+  if (i /= -42) call abort
+  close (10,status="delete")
+
+  end
diff --git a/gcc/testsuite/gfortran.dg/open_access_append_2.f90 b/gcc/testsuite/gfortran.dg/open_access_append_2.f90
new file mode 100644 (file)
index 0000000..3661bb0
--- /dev/null
@@ -0,0 +1,5 @@
+! { dg-do run }
+! Testcase for the GNU extension OPEN(...,ACCESS="APPEND")
+  open (10,err=900,access="append",position="asis") ! { dg-output ".*Extension.*" }
+  call abort
+ 900 end
index 29ebfd2..1fa1733 100644 (file)
@@ -1,3 +1,10 @@
+2005-11-17  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/24892
+       * io/io.h (unit_access): Add ACCESS_APPEND.
+       * io/open.c (access_opt): Add APPEND value for ACCESS keyword.
+       (st_open): Use that new value to set the POSITION accordingly.
+
 2005-11-14  Janne Blomqvist  <jb@gcc.gnu.org>
 
         PR fortran/21468
index e262677..47a564f 100644 (file)
@@ -153,7 +153,7 @@ namelist_info;
 /* Options for the OPEN statement.  */
 
 typedef enum
-{ ACCESS_SEQUENTIAL, ACCESS_DIRECT,
+{ ACCESS_SEQUENTIAL, ACCESS_DIRECT, ACCESS_APPEND,
   ACCESS_UNSPECIFIED
 }
 unit_access;
index 203964b..c3b5dde 100644 (file)
@@ -39,6 +39,7 @@ Boston, MA 02110-1301, USA.  */
 static const st_option access_opt[] = {
   {"sequential", ACCESS_SEQUENTIAL},
   {"direct", ACCESS_DIRECT},
+  {"append", ACCESS_APPEND},
   {NULL, 0}
 };
 
@@ -486,6 +487,19 @@ st_open (void)
     generate_error (ERROR_BAD_OPTION,
                    "Cannot use POSITION with direct access files");
 
+  if (flags.access == ACCESS_APPEND)
+    {
+      if (flags.position != POSITION_UNSPECIFIED
+         && flags.position != POSITION_APPEND)
+       generate_error (ERROR_BAD_OPTION, "Conflicting ACCESS and POSITION "
+                       "flags in OPEN statement");
+       
+      notify_std (GFC_STD_GNU,
+                 "Extension: APPEND as a value for ACCESS in OPEN statement");
+      flags.access = ACCESS_SEQUENTIAL;
+      flags.position = POSITION_APPEND;
+    }
+
   if (flags.position == POSITION_UNSPECIFIED)
     flags.position = POSITION_ASIS;