re PR ada/22255 (Reset on shared file causes Use_Error.)
authorSamuel Tardieu <sam@rfc1149.net>
Wed, 27 Feb 2008 12:12:14 +0000 (12:12 +0000)
committerSamuel Tardieu <sam@gcc.gnu.org>
Wed, 27 Feb 2008 12:12:14 +0000 (12:12 +0000)
    gcc/ada/
PR ada/22255
* s-fileio.adb (Reset): Do not raise Use_Error if mode isn't changed.

    gcc/testsuite/
PR ada/22255
* gnat.dg/test_direct_io.adb: New file.

From-SVN: r132708

gcc/ada/ChangeLog
gcc/ada/s-fileio.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/test_direct_io.adb [new file with mode: 0644]

index f509596..d86bfeb 100644 (file)
@@ -1,5 +1,10 @@
 2008-02-27  Samuel Tardieu  <sam@rfc1149.net>
 
+       PR ada/22255
+       * s-fileio.adb (Reset): Do not raise Use_Error if mode isn't changed.
+
+2008-02-27  Samuel Tardieu  <sam@rfc1149.net>
+
        PR ada/34799
        * sem_ch13.adb (Analyze_Record_Representation_Clause): Check
        that underlying type is present.
index a56877e..4a8393c 100644 (file)
@@ -1074,13 +1074,15 @@ package body System.File_IO is
    begin
       Check_File_Open (File);
 
-      --  Change of mode not allowed for shared file or file with no name
-      --  or file that is not a regular file, or for a system file.
-
-      if File.Shared_Status = Yes
-        or else File.Name'Length <= 1
-        or else File.Is_System_File
-        or else not File.Is_Regular_File
+      --  Change of mode not allowed for shared file or file with no name or
+      --  file that is not a regular file, or for a system file. Note that we
+      --  allow the "change" of mode if it is not in fact doing a change.
+
+      if Mode /= File.Mode
+        and then (File.Shared_Status = Yes
+                    or else File.Name'Length <= 1
+                    or else File.Is_System_File
+                    or else not File.Is_Regular_File)
       then
          raise Use_Error;
 
index f3285de..8d5fff7 100644 (file)
@@ -1,5 +1,10 @@
 2008-02-27  Samuel Tardieu  <sam@rfc1149.net>
 
+       PR ada/22255
+       * gnat.dg/test_direct_io.adb: New file.
+
+2008-02-27  Samuel Tardieu  <sam@rfc1149.net>
+
        PR ada/34799
        * gnat.dg/specs/pr34799.ads: New test.
 
diff --git a/gcc/testsuite/gnat.dg/test_direct_io.adb b/gcc/testsuite/gnat.dg/test_direct_io.adb
new file mode 100644 (file)
index 0000000..0eb8aa2
--- /dev/null
@@ -0,0 +1,15 @@
+-- { dg-do run }
+with Ada.Direct_IO;
+
+procedure Test_Direct_IO is
+
+   package BDIO is new Ada.Direct_IO (Boolean);
+   use BDIO;
+
+   FD : File_Type;
+
+begin
+   Create (FD, Form => "shared=yes");
+   Reset (FD);
+   Close (FD);
+end Test_Direct_IO;